diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-06-15 19:03:41 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-06-15 19:15:37 +0100 |
commit | 641611a690361c46b0c484d77379cecd70c869a6 (patch) | |
tree | d8080d7642e9def48b939a68e492ee309f3e1b63 /activerecord/lib | |
parent | ae3767c799708992f60442ab2e08b9108f01e5ed (diff) | |
download | rails-641611a690361c46b0c484d77379cecd70c869a6.tar.gz rails-641611a690361c46b0c484d77379cecd70c869a6.tar.bz2 rails-641611a690361c46b0c484d77379cecd70c869a6.zip |
Fix deprecation warnings when using config.active_record.mass_assignment_sanitizer=
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_assignment.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb index b36c90fc08..df4de8ac35 100644 --- a/activerecord/lib/active_record/attribute_assignment.rb +++ b/activerecord/lib/active_record/attribute_assignment.rb @@ -2,7 +2,7 @@ require 'active_support/concern' module ActiveRecord ActiveSupport.on_load(:active_record_config) do - mattr_accessor :whitelist_attributes, instance_accessor: false + mattr_accessor :whitelist_attributes, instance_accessor: false mattr_accessor :mass_assignment_sanitizer, instance_accessor: false end @@ -11,12 +11,12 @@ module ActiveRecord include ActiveModel::MassAssignmentSecurity included do - attr_accessible(nil) if Model.whitelist_attributes + initialize_mass_assignment_sanitizer end module ClassMethods def inherited(child) # :nodoc: - child.attr_accessible(nil) if Model.whitelist_attributes + child.send :initialize_mass_assignment_sanitizer if self == Base super end @@ -28,6 +28,11 @@ module ActiveRecord default << 'id' unless primary_key.eql? 'id' default end + + def initialize_mass_assignment_sanitizer + attr_accessible(nil) if Model.whitelist_attributes + self.mass_assignment_sanitizer = Model.mass_assignment_sanitizer if Model.mass_assignment_sanitizer + end end # Allows you to set all the attributes at once by passing in a hash with keys |