has_finder gem

Gem details

HasFinder is an extension to ActiveRecord that makes it easier than ever to create custom find and count queries.

Websitehttp://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries Tags with_scope, find, ActiveRecord

Documentation

Install the Gem:
gem install has_finder

You may have somthing that looks like this in your model:

class Post > ActiveRecord::Base

  def self.active
    find(:all, :conditions => {:active => true})
  end

end



HasFinder replaces this with

class Post > ActiveRecord::Base
	has_finder :active, :conditions => {:active => true}
end



so now you can do somthing like

Post.active.find(:all)



Or add some more conditions that will be merged

Post.active.find(:all, :conditions => {...})

Edit Gem | Back in time (2 older versions) | Last edited by: scott, 3 months ago