2009/9/25 Luis Mcdoguall <[email protected]>: > > clanlaw wrote: >> Why do you wish to do this? If it is for efficiency then are you sure >> you need it? You know that if you have a Master object @master then >> you can say @master.col1, @master.table1.col3 and @master.table2.col5. >> If in the find for @master you :include table1 and table2 it will do >> it all in one query. >> >> Colin > > The reasoning behind is that am going to to be using the console for > this application not html, and it will be nice if I can make the users > life more simple. > Later, I will be building the web interface, but for now all we need are > statistics. > > In any case I will like to know how to do it to satisfy my curiosity. > > When I use include I get : > Mysql::Error: Unknown column 'table1s.col3' in 'field list':...
You have mistyped the table name, it should be table1 not tabel1s. You can only put a table name in the include not the column name, which I imagine is the actual cause of the error. If this is just a typo in the email show us the code for the find with include. > > Then I tried :joints, and joints does not complain but the returned > values only include masters columns and non of the table-ns. Joins will not do anything for you here as these will be provided for you automatically by Rails based on the associations you have setup. I have not used :select but looking at the docs I think you want to use :include to specify the tables to include in the query combined with :select to limit it to the columns you want. Give this a go and if you cannot get it to work come back with the code you tried and the result. Also look in the log to see what the query this generated is. Colin --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

