Useful gems: Quick Scopes
Some time ago I’ve found an useful gem – internuity’s quick scopes.
As readme for the plugin says,
A Rails plugin to automatically add some quick named_scopes to your models.
These are especially useful for quick modifications to a query on an association.
It creates default named_scopes for any of your models:
- order
- limit
- offset
- with – alias for :include
- where – alias for :conditions
Personally I don’t like mixing named_scopes with :conditions and :order options – with this gem we can chain our scopes with limit, order etc:
user.posts.order('created_at')
user.posts.where(:published => true)
Another small thing that makes our code cleaner.
March 26th, 2009 at 12:28
Well,”order”, “limit”, “offset” – i used to define such scopes by myself, i’m not sure i need a gem to do that for me? I like the ‘where’ and ‘with’ idea doe.
March 26th, 2009 at 12:33
@marcin
I guess the point is you don’t have to do it anymore = cleaner code :)
December 15th, 2009 at 00:53
This gem is not compatible with Searchlogic :)