Active Record Associations:
Posted
by jmccartie
on Stack Overflow
See other posts from Stack Overflow
or by jmccartie
Published on 2010-05-03T02:22:54Z
Indexed on
2010/05/03
2:28 UTC
Read the original article
Hit count: 247
ruby-on-rails
|activerecord
I'm brand new to Rails, so bear with me.
I have 3 models: User, Section, and Tick.
Each section is created by a user. My guess with this association:
class Section < ActiveRecord::Base
has_one :user
end
Next, each user can "tick" off a section -- only once. So for each tick, I have a section_id, user_id, and timestamps. Here's where I'm stuck. Does this call for a "has_one :through" association? If so, which direction? If not, then I'm way off.
Which association works here?
Thanks!
© Stack Overflow or respective owner