Created
October 17, 2013 16:18
-
-
Save samsm/7027839 to your computer and use it in GitHub Desktop.
Hack for CanCan load_resource on Rails 4.
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
# 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