0

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

0

1 Answer 1

1

Try

class Bell < ActiveRecord::Base 

Note < instead of <<. Same for class Game. Also note that @bell_instance will have a game method, but not a games method (unless otherwise defined), because it only belongs to a single game.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.