Permalink
Browse files

Bypass mass assignment protection for Mongoid and AR

[closes #108]
  • Loading branch information...
1 parent aa7dd84 commit bfcdb3705fd39ac8720b45a6d2f27f370eb889dd @paulelliott committed Jun 11, 2012
@@ -5,7 +5,7 @@ def self.supports?(klass)
end
def build_instance
- self.__instance = __klass.new(__attributes)
+ self.__instance = __klass.new(__attributes, without_protection: true)
end
end
@@ -5,7 +5,7 @@ def self.supports?(klass)
end
def build_instance
- self.__instance = __klass.new(__attributes)
+ self.__instance = __klass.new(__attributes, without_protection: true)
end
end
@@ -49,6 +49,7 @@ class ChildActiveRecordModel < ActiveRecord::Base
class ParentActiveRecordModel < ActiveRecord::Base
has_many :child_active_record_models
+ attr_protected :number_field
before_save do
self.before_save_value = 11
View
@@ -21,6 +21,8 @@ class ParentMongoidDocument
references_many :referenced_mongoid_documents
+ attr_protected :number_field
+
before_save do
self.before_save_value = 11
end

0 comments on commit bfcdb37

Please sign in to comment.