Created
October 5, 2008 22:28
-
-
Save trevorturk/14948 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
# config/initializers/log_protected_attribute_removal.rb | |
# raises an exception in test environment when trying to mass assign protected attributes | |
# detail: http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment | |
if RAILS_ENV == 'test' | |
ActiveRecord::Base.class_eval do | |
def log_protected_attribute_removal(*attributes) | |
raise "Can't mass-assign these protected attributes: #{attributes.join(', ')}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment