Skip to content

Instantly share code, notes, and snippets.

@samsm
Created October 17, 2013 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samsm/7027839 to your computer and use it in GitHub Desktop.
Save samsm/7027839 to your computer and use it in GitHub Desktop.
Hack for CanCan load_resource on Rails 4.
# Hack to get strong_parameters working
CanCan::ControllerResource
class CanCan::ControllerResource
protected
# Before using @params[whatever], CanCan will try calling whatever_params
def resource_params_by_namespaced_name
@controller.send(:"#{extract_key(namespaced_name)}_params")
rescue NoMethodError
@params[extract_key(namespaced_name)]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment