Class: Spree::Api::ImagesController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#map_nested_attributes_keys, #set_jsonp_format

Methods included from ControllerSetup

included

Instance Method Details

#createObject



11
12
13
14
15
# File 'app/controllers/spree/api/images_controller.rb', line 11

def create
  authorize! :create, Image
  @image = Image.create(params[:image])
  respond_with(@image, :status => 201, :default_template => :show)
end

#destroyObject



24
25
26
27
28
29
# File 'app/controllers/spree/api/images_controller.rb', line 24

def destroy
  authorize! :delete, Image
  @image = Image.find(params[:id])
  @image.destroy
  respond_with(@image, :status => 204)
end

#showObject



6
7
8
9
# File 'app/controllers/spree/api/images_controller.rb', line 6

def show
  @image = Image.find(params[:id])
  respond_with(@image)
end

#updateObject



17
18
19
20
21
22
# File 'app/controllers/spree/api/images_controller.rb', line 17

def update
  authorize! :update, Image
  @image = Image.find(params[:id])
  @image.update_attributes(params[:image])
  respond_with(@image, :default_template => :show)
end