Created
October 30, 2012 20:03
-
-
Save aaronjensen/3982631 to your computer and use it in GitHub Desktop.
Force strong parameters
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
# Place in config/initializers | |
ActiveRecord::Base.class_eval do | |
class << self | |
def inherited_with_strong_params(sub) | |
inherited_without_strong_params(sub) | |
# Filter out plugin models that won't work with strong_parameters yet | |
unless sub.name =~ /^doorkeeper/i | |
sub.send :include, ActiveModel::ForbiddenAttributesProtection | |
end | |
end | |
alias_method_chain :inherited, :strong_params | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. I was just looking how best to do this for exactly this use case.