Skip to content
Bogdan Gusiev edited this page Aug 22, 2013 · 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 ProjectsGrid
 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 = ProjectsGrid.new(params[:my_grid]) do
  current_user.projects
end

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