Module: ActiveAdmin::Resource::Scopes
- Included in:
- ActiveAdmin::Resource
- Defined in:
- lib/active_admin/resource/scopes.rb
Instance Method Summary collapse
- #default_scope ⇒ Object
-
#get_scope_by_id(id) ⇒ Object
Returns a scope for this object by its identifier.
-
#scope(*args, &block) ⇒ Object
Create a new scope object for this resource.
-
#scopes ⇒ Object
Return an array of scopes for this resource.
Instance Method Details
#default_scope ⇒ Object
16 17 18 |
# File 'lib/active_admin/resource/scopes.rb', line 16 def default_scope @default_scope end |
#get_scope_by_id(id) ⇒ Object
Returns a scope for this object by its identifier
11 12 13 14 |
# File 'lib/active_admin/resource/scopes.rb', line 11 def get_scope_by_id(id) id = id.to_s scopes.find{|s| s.id == id } end |
#scope(*args, &block) ⇒ Object
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”.
23 24 25 26 27 28 29 |
# File 'lib/active_admin/resource/scopes.rb', line 23 def scope(*args, &block) = args. self.scopes << ActiveAdmin::Scope.new(*args, &block) if [:default] @default_scope = scopes.last end end |
#scopes ⇒ Object
Return an array of scopes for this resource
6 7 8 |
# File 'lib/active_admin/resource/scopes.rb', line 6 def scopes @scopes ||= [] end |