-
Notifications
You must be signed in to change notification settings - Fork 116
Scope
bogdan edited this page Jul 19, 2012
·
18 revisions
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 = ?