You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
amalagaura edited this page Jan 3, 2012
·
4 revisions
We can create dynamic scopes which are defined at initialization time (so not completely dynamic in production, the initializer will only be loaded at startup).
Here is an example where item_types are a category table and items belong to item_type through the item_type_id.
ActiveAdmin.register Item do
scope :all, :default => true
Category.all.each do |category|
self.send(:scope, category.name) do |items|
items.where(:category_id => category.id)
end
end
end