Skip to content
bogdan edited this page Jun 13, 2012 · 18 revisions

Scope

Simple scope definition

Datagrid scope as assets source to be queried from the database. In most cases it is a model class with some default ORM scopes like order or includes:

class MyGrid
 include Datagrid
 scope { Project.includes(:category) }
end

Scope is also used to choose a ORM driver(MongoMapper, Mongoid or ActiveRecord), get wether filters and columns defined below has order.

In some cases you can to change the scope of the fly (version >= 0.6.1):

grid = MyGrid.new
grid.scope do
  current_user.projects
end

grid.assets # SELECT * FROM projects WHERE projects.user_id = ?
Clone this wiki locally