Module: Her::Model::ORM::CreateMethods::ClassMethods
- Defined in:
- lib/her/model/orm/create_methods.rb
Instance Method Summary collapse
-
#create(params = {}) ⇒ Object
Create a resource and return it.
- #create!(params = {}) ⇒ Object
Instance Method Details
#create(params = {}) ⇒ Object
Create a resource and return it
13 14 15 16 17 |
# File 'lib/her/model/orm/create_methods.rb', line 13 def create(params = {}) resource = new(params) resource.save resource end |
#create!(params = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/her/model/orm/create_methods.rb', line 19 def create!(params = {}) resource = create(params) raise RecordInvalid.new(resource.errors) unless resource.errors.empty? resource end |