Skip to content

Latest commit

 

History

History
99 lines (45 loc) · 1.36 KB

ClassMethods.rst

File metadata and controls

99 lines (45 loc) · 1.36 KB

ClassMethods

Constants

Files

Methods

#create

Creates a new relationship between objects

ruby

def create(props = {})

relationship_props = extract_association_attributes!(props) || {} new(props).tap do relationship_props.each do obj.send("#{prop}=", value) end obj.save end

end

#create!

Same as #create, but raises an error if there is a problem during save.

ruby

def create!(*args)

props = args[0] || {} relationship_props = extract_association_attributes!(props) || {} new(props).tap do relationship_props.each do obj.send("#{prop}=", value) end obj.save! end

end

#create_method

ruby

def create_method

creates_unique? ? :create_unique : :create

end