Navigation Menu

Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Bypass mass assignment protection for Mongoid and AR
Browse files Browse the repository at this point in the history
[closes #108]
  • Loading branch information
paulelliott committed Jun 11, 2012
1 parent aa7dd84 commit bfcdb37
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fabrication/generator/active_record.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/fabrication/generator/mongoid.rb
Expand Up @@ -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
1 change: 1 addition & 0 deletions spec/support/active_record.rb
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/support/mongoid.rb
Expand Up @@ -21,6 +21,8 @@ class ParentMongoidDocument

references_many :referenced_mongoid_documents

attr_protected :number_field

before_save do
self.before_save_value = 11
end
Expand Down

0 comments on commit bfcdb37

Please sign in to comment.