diff options
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 14 | ||||
-rwxr-xr-x | activerecord/test/base_test.rb | 18 | ||||
-rw-r--r-- | railties/environments/production.rb | 3 |
4 files changed, 2 insertions, 35 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index c196e24ac7..061fe0f46e 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -82,7 +82,7 @@ * validates_uniqueness_of behaves well with abstract superclasses and single-table inheritance. #3833, #9886 [Gabriel Gironda, rramdas, François Beausoleil, Josh Peek, Tarmo Tänav, pat] -* Raise ProtectedAttributeAssignmentError in development and test environments when mass-assigning to an attr_protected attribute. #9802 [Henrik N] +* Warn about protected attribute assigments in development and test environments when mass-assigning to an attr_protected attribute. #9802 [Henrik N] * Speedup database date/time parsing. [Jeremy Kemper, Tarmo Tänav] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 3e7fa13e97..991d8b040c 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -35,8 +35,6 @@ module ActiveRecord #:nodoc: end class Rollback < ActiveRecordError #:nodoc: end - class ProtectedAttributeAssignmentError < ActiveRecordError #:nodoc: - end class DangerousAttributeError < ActiveRecordError #:nodoc: end @@ -359,11 +357,6 @@ module ActiveRecord #:nodoc: cattr_accessor :schema_format , :instance_writer => false @@schema_format = :ruby - # Determines whether to raise an exception on mass-assignment to protected - # attributes. Defaults to true. - cattr_accessor :whiny_protected_attributes, :instance_writer => false - @@whiny_protected_attributes = true - class << self # Class methods # Find operates with three different retrieval approaches: # @@ -2101,12 +2094,7 @@ module ActiveRecord #:nodoc: removed_attributes = attributes.keys - safe_attributes.keys if removed_attributes.any? - error_message = "Can't mass-assign these protected attributes: #{removed_attributes.join(', ')}" - if self.class.whiny_protected_attributes - raise ProtectedAttributeAssignmentError, error_message - else - logger.error error_message - end + logger.debug "WARNING: Can't mass-assign these protected attributes: #{removed_attributes.join(', ')}" end safe_attributes diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 103f9f7271..e17b2a1b57 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -67,13 +67,6 @@ end class BasicsTest < Test::Unit::TestCase fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics - # whiny_protected_attributes is turned off since several tests were - # not written with it in mind, and would otherwise raise exceptions - # as an irrelevant side-effect. - def setup - ActiveRecord::Base.whiny_protected_attributes = false - end - def test_table_exists assert !NonExistentTable.table_exists? assert Topic.table_exists? @@ -861,17 +854,6 @@ class BasicsTest < Test::Unit::TestCase assert_equal [ :name, :address, :phone_number ], TightDescendant.accessible_attributes end - def test_whiny_protected_attributes - ActiveRecord::Base.whiny_protected_attributes = true - assert_raise(ActiveRecord::ProtectedAttributeAssignmentError) do - LoosePerson.create!(:administrator => true) - end - ActiveRecord::Base.whiny_protected_attributes = false - assert_nothing_raised do - LoosePerson.create!(:administrator => true) - end - end - def test_readonly_attributes assert_equal [ :title ], ReadonlyTitlePost.readonly_attributes diff --git a/railties/environments/production.rb b/railties/environments/production.rb index 2bc0669341..cb295b83f1 100644 --- a/railties/environments/production.rb +++ b/railties/environments/production.rb @@ -16,6 +16,3 @@ config.action_controller.perform_caching = true # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false - -# Disable raising errors when mass-assigning to a protected attribute -config.active_record.whiny_protected_attributes = false |