[Rails] Rails theory question, where to put a join query
Horacio J. Peña
horape at compendium.com.ar
Wed Aug 16 16:34:48 GMT 2006
> Say you have two tables with two models, 'authors' and 'posts'.
> an author has_many posts, a post has_one author.
A post belongs_to author would be the right way.
> You need methods to do the following queries:
>
> find_author(postid)
> find_posts(authorid)
>
> And you are doing a custom join query for both. How do you decide what
> model they go into? To me either can make sense, so I am uncomfortable with
> picking one.
Why do you do custom joins? Use associations.
Saludos!
HoraPe
---
Horacio J. Peña
horape at compendium.com.ar
horape at uninet.edu
More information about the Rails
mailing list