User and Game Association help.

Christopher Jones
2012-02-01T01:16:45Z

Hi all, I am currently doing work on my rails project and have hit a
wall. I am quite new to Rails so at the moment only know a little bit
about it.

I have a users table and a games table. At the moment I am able to enter
in user information as well as add new games to the games table.

What I wish to do now is to combine the both using a foreign key. I have
added the user_id entry to the games table and even declared it as a
foreign key by writing it as a command through MySQL. I have also
declared them as followed:

model Games < ActiveRecord::Base
  belongs_to :user
end
model User < ActiveRecord::Base
  has_many :games
end

Is there anything else I must do. I want to be able to on the user
profile show all games associated with that particular user. How would I
go about doing this?

Any help would be greatly appreciated.

--
Posted via http://www.ruby-forum.com/.