Method: Her::Model::Relation#create

Defined in:
lib/castle-her/model/relation.rb

#create(attributes = {}) ⇒ Object

Create a resource and return it

Examples:

@user = User.create(:fullname => "Tobias Fünke")
# Called via POST "/users/1" with `&fullname=Tobias+Fünke`
@user = User.where(:email => "[email protected]").create(:fullname => "Tobias Fünke")
# Called via POST "/users/1" with `&[email protected]&fullname=Tobias+Fünke`


121
122
123
124
125
126
127
# File 'lib/castle-her/model/relation.rb', line 121

def create(attributes = {})
  attributes ||= {}
  resource = @parent.new(@params.merge(attributes))
  resource.save

  resource
end