In my User model I could have:
has_many :tasks
and in my Task model:
belongs_to :user
Then, supposing the foreign key 'user_id' was stored in the tasks table, I could use:
@user.tasks
My question is, how do I declare the has_many relationship such that I can refer to a User's Tasks as:
@user.jobs
... or ...
@user.foobars
Thanks a heap.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…