# File lib/active_record/mass_assignment_security/associations.rb, line 97 def build(attributes = {}, options = {}) record = build_record(attributes, options) yield(record) if block_given? set_new_record(record) record end
# File lib/active_record/mass_assignment_security/associations.rb, line 89 def create(attributes = {}, options = {}, &block) create_record(attributes, options, &block) end
# File lib/active_record/mass_assignment_security/associations.rb, line 93 def create!(attributes = {}, options = {}, &block) create_record(attributes, options, true, &block) end
# File lib/active_record/mass_assignment_security/associations.rb, line 104 def create_record(attributes, options = {}, raise_error = false) record = build_record(attributes, options) yield(record) if block_given? saved = record.save set_new_record(record) raise RecordInvalid.new(record) if !saved && raise_error record end