module ActiveAdmin::Resource::ScopeTo
def scope_to(*args, &block)
scope_to :current_user, unless: proc{ current_user.admin? }
or
scope_to :current_user, if: proc{ admin_user_signed_in? }
To conditionally use this scope, you can use conditional procs
current_user.blog_posts.build
will result in the following
scope_to :current_user, association_method: :blog_posts
pass in the association_method as an option.
method to call as the association. If its different, you can
By default Active Admin will use the resource name to build a
current_user.posts.build
Then every time we instantiate and object, it would call
end
scope_to :current_user
ActiveAdmin.register Post do
Eg:
of a method to call.
to the resource. Can either accept a block or a symbol
Scope this controller to some object which has a relation
def scope_to(*args, &block) options = args.extract_options! method = args.first scope_to_config[:method] = block || method scope_to_config[:association_method] = options[:association_method] scope_to_config[:if] = options[:if] scope_to_config[:unless] = options[:unless] end