Well, I decided to bite the bullet and get closer to the metal by
using :joins and :select. That worked great. Now my query is very
compact -- with only those columns I need in the table and there are
no extra count-related queries. It was a bit of a surprise for me that
when :include was used, :select was ignored, but it does make sense.

So when I use :select and :join rails creates attr_readers for each of
the selected columns? For example, I used to have lines like <%=
ticket.priority.name %> in my view. When I changed to using :select, I
changed that line to <%= ticket.priority_name %> because in my :select
I retrieve the priority name directly from the db (by joining the
tickets table with the priorities table). So, I was expecting to see
something like "the ticket model doesn't have a member named
'priority_name'", but nope, no error occurred. So, my guess is that
rails created an attr_reader for each of the columns mentioned
in :select. Is that approximately what happens?

Thank you, Erol, Conrad and everybody else for helping me!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to