app/controllers/admin/manager_controller.rb in ab_admin-0.7.0 vs app/controllers/admin/manager_controller.rb in ab_admin-0.8.0

- old
+ new

@@ -21,13 +21,17 @@ def button_scopes manager.scopes.map{|scope| [scope.name, scope.options] } end def with_scopes(relation) - manager.scopes.inject(relation) { |result, scope| scope.apply(result, params) } + scopes_to_apply.inject(relation) { |result, scope| scope.apply(result, params) } end + def scopes_to_apply + manager.scopes.find_all{|scope| params[scope.name].present? } + end + def begin_of_association_chain parent end def parent @@ -123,16 +127,10 @@ raise ActionController::RoutingError.new("AbAdmin model #{params[:model_name]} not found (#{e.message})") end end def permitted_params - attrs = case manager.permitted_params - when Proc then - instance_exec(&manager.permitted_params) - else - Array(manager.permitted_params) - end - + attrs = Array(manager.permitted_params.is_a?(Proc) ? instance_exec(&manager.permitted_params) : manager.permitted_params) resource_params = params[resource_class.model_name.param_key] return {} unless resource_params if attrs.first == :all resource_params.permit! else