On Thu, Nov 15, 2012 at 10:37 AM, Colin Law <clan...@googlemail.com> wrote: > Experimentation shows me that you are right, that is a bit of rails > magic that I was not aware of. In fact it seems that one can call any > class method on an ActiveRecord relation for the class. Thanks for > the education.
It's one of my favorite things to do with ActiveRecord, especially when storing certain types of records in things like Memcached where security is more of a cocern to me than a database (in that it has no scoped ACL like our db's) so I always do something like only with a where or find_by_* especially since arel (or it might be activerecord itself) is smart enough to build the entire query long before the last method in the chain. > So the question is, is there any significant difference between a > scope with a lambda and a class method performing the same operation? >From my own experience it depends, sometimes it could be a matter of just reordering your chain in some cases it might not work at all. One would have to provide scenarios for a question like this because it's really up in the air with such a broad scope. -- 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 rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.