Skip to content

HowTo : Handle complex queries

giniedp edited this page Jul 4, 2012 · 4 revisions

To handle large queries with lots of conditions just add a block to the find method. The query parameter is a magic wrapper around your resource class and will chain all called methods. If you use active record ORM then you can call everything that you would call after find on an ActiveRecord class.

fancygrid_for :users do |grid|
  # ...
  grid.find do |query|
    query.where :foo => :bar
    query.includes :address
    query.my_scope.my_other_scope
  end
end