Class: Integral::Backend::ImagesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Integral::Backend::ImagesController
- Defined in:
- app/controllers/integral/backend/images_controller.rb
Overview
Images controller
Instance Method Summary collapse
-
#create ⇒ Object
POST / Image creation.
-
#destroy ⇒ Object
DELETE /:id.
-
#edit ⇒ Object
GET /:id/edit Image edit form.
-
#index ⇒ Object
GET / Lists all images.
-
#new ⇒ Object
GET /new Image creation form.
-
#update ⇒ Object
PUT /:id Updating an image.
Instance Method Details
#create ⇒ Object
POST / Image creation
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/integral/backend/images_controller.rb', line 36 def create @image = Image.new(image_params) if remote_request? if @image.save flash.now[:notice] = ('creation_success') render json: @image.to_list_item, status: :created else flash.now[:error] = ('creation_failure') head :unprocessable_entity end else if @image.save respond_successfully(('creation_success'), edit_backend_img_path(@image)) else respond_failure(('creation_failure'), @image, :new) end end end |
#destroy ⇒ Object
DELETE /:id
73 74 75 76 77 78 79 80 |
# File 'app/controllers/integral/backend/images_controller.rb', line 73 def destroy if @image.destroy respond_successfully(('delete_success'), backend_img_index_path) else flash[:error] = ('delete_failure') redirect_to backend_img_index_path end end |
#edit ⇒ Object
GET /:id/edit Image edit form
58 59 60 |
# File 'app/controllers/integral/backend/images_controller.rb', line 58 def edit I18n.t('integral.navigation.edit'), :edit_backend_img_path end |
#index ⇒ Object
GET / Lists all images
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/integral/backend/images_controller.rb', line 10 def index respond_to do |format| format.html do set_grid(Integral::Grids::ImagesGrid) end format.json do if params[:gridview].present? set_grid(Integral::Grids::ImagesGrid) render json: { content: render_to_string(partial: 'integral/backend/images/grid', locals: { grid: @grid }) } else respond_to_record_selector(Integral::Image) end end end end |
#new ⇒ Object
GET /new Image creation form
29 30 31 32 |
# File 'app/controllers/integral/backend/images_controller.rb', line 29 def new I18n.t('integral.navigation.new'), :new_backend_img_path @image = Image.new end |
#update ⇒ Object
PUT /:id Updating an image
64 65 66 67 68 69 70 |
# File 'app/controllers/integral/backend/images_controller.rb', line 64 def update if @image.update(image_params) respond_successfully(('edit_success'), backend_img_index_path) else respond_failure(('edit_failure'), @image, :edit) end end |