I have a database containing around 15 tables. There are lots of
relationships. Now if I need to add a query involving say 8
tables(a,b,c,d,e,f,g,h) can I do it using find_by_sql. If so where do I
implement the method, inside the class of which table.
I have a database containing around 15 tables. There are lots of
relationships. Now if I need to add a query involving say 8
tables(a,b,c,d,e,f,g,h) can I do it using find_by_sql.
You can do anything you want pretty much using find_by_sql
If so where do I
implement the method, inside the class of which table.
If you call Foo.find_by_sql will return an array of objects of class
Foo. With that in mind it's completely up to you
Just pick one. It doesn't much matter to you what kind of object is
returned by find_by_sql (or connection.execute). It'll have attributes
for every column in the SELECT. So pick one as a "controller" (our
term, not Rails') and go through it. It's really just a matter of self-
documentation. In what model would you look for this method?