Class: Api::OrdersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/orders_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



30
31
32
33
34
35
36
37
# File 'app/controllers/api/orders_controller.rb', line 30

def destroy
@object=Order.find_by_id(params[:id])
@object.destroy
if @object.destroy
 render :text => 'Destroyed' 
 end

end

#updateObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/api/orders_controller.rb', line 20

def update
  @object=Order.find_by_id(params[:id])
  if @object.update_attributes(params[object_name])
    
    @response=Order.find_by_id(@object.id)
    render :json => @response.to_json, :status => 201
  else
    respond_with(@object.errors, :status => 422)
  end
end