Class: Integral::Backend::ImagesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/integral/backend/images_controller.rb

Overview

Images controller

Instance Method Summary collapse

Methods inherited from BaseController

#activities, #activity, #duplicate, #index

Instance Method Details

#createObject

POST / Image creation



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/integral/backend/images_controller.rb', line 17

def create
  @resource = Image.new(resource_params)

  if remote_request?
    if @resource.save
      flash.now[:notice] = notification_message('creation_success')
      render json: @resource.to_list_item, status: :created
    else
      flash.now[:error] = notification_message('creation_failure')
      head :unprocessable_entity
    end
  elsif @resource.save
    respond_successfully(notification_message('creation_success'), edit_backend_img_path(@resource))
  else
    respond_failure(notification_message('creation_failure'), :new)
  end
end

#destroyObject

DELETE /:id



52
53
54
55
56
57
58
59
# File 'app/controllers/integral/backend/images_controller.rb', line 52

def destroy
  if @resource.destroy
    respond_successfully(notification_message('delete_success'), backend_img_index_path)
  else
    flash[:error] = notification_message('delete_failure')
    redirect_to backend_img_index_path
  end
end

#editObject

GET /:id/edit Image edit form



37
38
39
# File 'app/controllers/integral/backend/images_controller.rb', line 37

def edit
  add_breadcrumb I18n.t('integral.navigation.edit'), :edit_backend_img_path
end

#newObject

GET /new Image creation form



10
11
12
13
# File 'app/controllers/integral/backend/images_controller.rb', line 10

def new
  add_breadcrumb I18n.t('integral.navigation.new'), :new_backend_img_path
  @resource = Image.new
end

#updateObject

PUT /:id Updating an image



43
44
45
46
47
48
49
# File 'app/controllers/integral/backend/images_controller.rb', line 43

def update
  if @resource.update(resource_params)
    respond_successfully(notification_message('edit_success'), backend_img_index_path)
  else
    respond_failure(notification_message('edit_failure'), :edit)
  end
end