Class: Spree::Api::V1::ImagesController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#content_type, #permitted_line_item_attributes
included
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/spree/api/v1/images_controller.rb', line 17
def create
authorize! :create, Image
@image = scope.images.new(image_params)
if @image.save
respond_with(@image, status: 201, default_template: :show)
else
invalid_resource!(@image)
end
end
|
#destroy ⇒ Object
36
37
38
39
40
|
# File 'app/controllers/spree/api/v1/images_controller.rb', line 36
def destroy
@image = scope.images.accessible_by(current_ability, :destroy).find(params[:id])
@image.destroy
respond_with(@image, status: 204)
end
|
#index ⇒ Object
5
6
7
8
|
# File 'app/controllers/spree/api/v1/images_controller.rb', line 5
def index
@images = scope.images.accessible_by(current_ability, :read)
respond_with(@images)
end
|
#new ⇒ Object
15
|
# File 'app/controllers/spree/api/v1/images_controller.rb', line 15
def new; end
|
#show ⇒ Object
10
11
12
13
|
# File 'app/controllers/spree/api/v1/images_controller.rb', line 10
def show
@image = Image.accessible_by(current_ability, :read).find(params[:id])
respond_with(@image)
end
|
#update ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'app/controllers/spree/api/v1/images_controller.rb', line 27
def update
@image = scope.images.accessible_by(current_ability, :update).find(params[:id])
if @image.update_attributes(image_params)
respond_with(@image, default_template: :show)
else
invalid_resource!(@image)
end
end
|