module ActiveAdmin::ScopeChain

Public Instance Methods

scope_chain(scope, chain) click to toggle source

Scope an ActiveRecord::Relation chain

Example:

scope_chain(Scope.new(:published), Article)
# => Article.published

@param scope The <ActiveAdmin::Scope> we want to scope on @param chain The ActiveRecord::Relation chain or ActiveRecord::Base class to scope @return <ActiveRecord::Relation or ActiveRecord::Base> The scoped relation chain

# File lib/active_admin/helpers/scope_chain.rb, line 13
def scope_chain(scope, chain)
  if scope.scope_method
    chain.public_send scope.scope_method
  elsif scope.scope_block
    instance_exec chain, &scope.scope_block
  else
    chain
  end
end