0

내 응용 프로그램을 실행할 때 NameError이 발생합니다.기존 이름의 NameError

NameError in CountriesController#index 
undefined local variable or method `country_code' for Country(id: integer, name: string, country_code: string):Class 

이 코드의 어딘가에 있지만 이해가되지 않습니다. 나는 내 country_code가 있지만 그것은 존재하지 않는다고 말합니다.

class Country < ActiveRecord::Base 
    validates country_code, presence: true 
    validates name, presence: true 
    has_and_belongs_to_many :groups 

누구든지 해결 방법을 알고 있습니까?

답변

5
class Country < ActiveRecord::Base 
validates :country_code, presence: true 
validates :name, presence: true 
has_and_belongs_to_many :groups 

당신은 변수 기호를

+0

감사해야! 나를 위해 일한다! – user3383458