Frage

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?

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top