Class: Portfolio::Admin::SiteItemImagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/portfolio/admin/site_item_images_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/portfolio/admin/site_item_images_controller.rb', line 8

def create
  @image = SiteItemImage.new(image_params)

  if @image.save
    redirect_to edit_project_path, notice: 'Image was successfully created.'
  else
    @item = @item_project.item
    render template: 'portfolio/item_projects/edit'
  end
end

#destroyObject



32
33
34
35
# File 'app/controllers/portfolio/admin/site_item_images_controller.rb', line 32

def destroy
  @image.destroy
  redirect_to edit_project_path, notice: 'Image was successfully destroyed.'
end

#set_defaultObject



27
28
29
30
# File 'app/controllers/portfolio/admin/site_item_images_controller.rb', line 27

def set_default
  @image.update(default: true)
  redirect_to edit_project_path, notice: 'Image was successfully updated.'
end

#updateObject



19
20
21
22
23
24
25
# File 'app/controllers/portfolio/admin/site_item_images_controller.rb', line 19

def update
  if @image.update(image_params)
    redirect_to edit_project_path, notice: 'Image was successfully updated.'
  else
    render :edit
  end
end