I see that, but sometimes you want to reuse code in the same relation. For instance if you do a query first using restricted columns and later you need to do a count based on the result. Let's say in the first relation with selected columns (col1, col2, etc.) you want to use to fill an array. From what I understand it doesn't work if I try to obtain a count from this relation. In fact, it doesn't make sense to do a relation just to do a count.
In this scenario you would need two relations, one for the selected columns and another only for count. I would prefer do it using raw SQL, don't you agree? Rod josh.jor...@gmail.com wrote in post #1148444: > If you're calling count, it doesn't matter what select values you've > passed, since you're asking ActiveRecord to return an aggregate, not any > column values. > > > On Sun, Jun 1, 2014 at 9:19 AM, Rodrigo Lueneberg <li...@ruby-forum.com> -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f824781ea8e576e1eec1c6341083e02d%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.