From the few details you gave, it is a little hard to guess, what you are trying to do. But I'll try anyway:
When you want a person to have exactly one mood at a time, I would model it like this:
class Person < ActiveRecord::Base
belongs_to :mood
end
class Mood < ActiveRecord::Base
has_many :people
end
The migration to create the people table in the database should then include the following statement to create a foreign key:
def self.up
create_table :people do |t|
...
t.references :mood
...
end
end
If this is what you want, you can use the collection_select
command as flyfishr64 pointed out.
Inside the form_for
tag in new.html.erb you would write something like this:
<% form_for @person do |f| %>
...
<%= f.collection_select :mood_id, Mood.all, :id, :mood_name, :include_blank => "--- Choose your mood ---" %>
...
<% end %>
Hope that helps!
However, when you really want your person to have multiple moods simultaneously, this would be a little more complicated, and I probably would suggest to use the has_and_belongs_to_many
association in both models.
If that's the case, I would recommend watching this Railscast episode: HABTM Checkboxes. (Sorry, you have to look for the link yourself, as I am not allowed to post more than one line. Go to railscast.com and look for episode 17.)