I have two models as follows:
class Game << ActiveRecord::Base
has_many :bells
end
class Bell << ActiveRecord::Base
belongs_to :game
end
Now when I open the rails console, I type: @bell_instance.games.title (I get an uninitialized constant Bell::Game. When I type @bell_instance.game.title (I get an undefined method “game”). I really dont know whats wrong, this seems very simple.
I also tried adding the :foreign_key option but I get the same errors.
PS: Game has a :title field
Try
Note
<instead of<<. Same forclass Game. Also note that@bell_instancewill have agamemethod, but not agamesmethod (unless otherwise defined), because it only belongs to a single game.