Method: Mongoid::Attributes#assign_attributes
- Defined in:
- lib/mongoid/attributes.rb
#assign_attributes(attrs = nil, options = {}) ⇒ Object
Allows you to set all the attributes for a particular mass-assignment security role by passing in a hash of attributes with keys matching the attribute names (which again matches the column names) and the role name using the :as option. To bypass mass-assignment security you can use the :without_protection => true option.
131 132 133 134 135 136 137 |
# File 'lib/mongoid/attributes.rb', line 131 def assign_attributes(attrs = nil, = {}) _assigning do process(attrs, [:as] || :default, ![:without_protection]) do |document| document.identify if new? && id.blank? end end end |