On Fri, Jan 29, 2010 at 10:52 PM, Steve Castaneda <li...@ruby-forum.com> wrote: > Jamey Cribbs wrote: >> Sounds like you do not have your associations defined correctly in your >> model. >> >> In your Buyer model you should have this line: >> >> belongs_to :status >> >> In your Status model you should have this line: >> >> has_many :buyers >> >> >> HTH, >> >> Jamey > > That was it! Thank you so much. I was totally getting confused here: > > belongs_to :status vs. has_one :status > > Can you help me understand why it's belongs_to and not has_one? A > status is part of a buyer, so I guess I just get confused on the logic.
The big difference between has_one and belongs_to is that ActiveRecord expects the model that uses the belongs_to to have a foreign key identifying the associated record in the other table. So, therefore you know you need to use a belongs_to in Buyer because that the buyers table is where you have defined the status_id field. HTH, Jamey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.