문제

I get this NameError when executing my application.

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

It's somewhere in this code, but I don't understand it. I have my country_code, but It says it's inexistant.

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

Does anyone know how to fix this?

도움이 되었습니까?

해결책

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

You need to make the variables symbols

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top