lib/active_admin/resource/scopes.rb in activeadmin-0.6.0 vs lib/active_admin/resource/scopes.rb in activeadmin-0.6.1
- old
+ new
@@ -11,12 +11,18 @@
def get_scope_by_id(id)
id = id.to_s
scopes.find{|s| s.id == id }
end
- def default_scope
- @default_scope
+ def default_scope(context = nil)
+ scopes.detect do |scope|
+ if scope.default_block.is_a?(Proc)
+ render_in_context(context, scope.default_block)
+ else
+ scope.default_block
+ end
+ end
end
# Create a new scope object for this resource.
# If you want to internationalize the scope name, you can add
# to your i18n files a key like "active_admin.scopes.scope_method".
@@ -33,11 +39,9 @@
scopes.delete_at(existing_scope_index)
scopes.insert(existing_scope_index, scope)
else
self.scopes << scope
end
-
- @default_scope = scope if options[:default]
scope
end
end