Created
March 15, 2013 14:44
-
-
Save paukul/5170332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/monkey/cancan/controller_resource.rb | |
module CanCan | |
class ControllerResource | |
protected | |
def strong_parameters? | |
@params.class.name == 'ActionController::Parameters' | |
end | |
def resource_params | |
if [:create, :update].member? @params[:action].to_sym | |
param_name = @options[:instance_name] || (@options[:class] || namespaced_name).to_s.underscore.gsub('/', '_') | |
if strong_parameters? || @options[:params] | |
params_method = (@options[:params] == true || ! @options[:params]) ? | |
"#{param_name}_params" : @options[:params] | |
return @controller.send params_method if @controller.send :respond_to?, params_method | |
end | |
@params[param_name] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment