class ActiveRecord::Associations::SingularAssociation
Public Instance Methods
build(attributes = {}, options = {}) { |record| ... }
click to toggle source
# File lib/active_record/mass_assignment_security/associations.rb, line 118 def build(attributes = {}, options = {}) record = build_record(attributes, options) yield(record) if block_given? set_new_record(record) record end
create(attributes = {}, options = {}, &block)
click to toggle source
# File lib/active_record/mass_assignment_security/associations.rb, line 110 def create(attributes = {}, options = {}, &block) create_record(attributes, options, &block) end
create!(attributes = {}, options = {}, &block)
click to toggle source
# File lib/active_record/mass_assignment_security/associations.rb, line 114 def create!(attributes = {}, options = {}, &block) create_record(attributes, options, true, &block) end
Private Instance Methods
create_record(attributes, options = {}, raise_error = false) { |record| ... }
click to toggle source
# File lib/active_record/mass_assignment_security/associations.rb, line 125 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