[Rails] Join two models
Need some help with understanding the best way of doing the
following:
I have a user model and two models (link_post and text_post) i now
want to join the models together as post.
both link_post and text_post has a user_id column.
What a i want is to get
u = User.first
u.posts
to collect all link_post and text_post together.
Should this be done with a scope or with some model association ? I
don't need a controller for posts just the self join.
But if i can get other scopes on "posts" it would be great... (like
published_on etc ...)
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home