Class: PhotosController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/photos_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

post /photos



17
18
19
20
21
22
23
24
# File 'app/controllers/photos_controller.rb', line 17

def create
  @entity = Photo.new(creation_parameters)
  if @entity.save
    redirect_to(admin_photo_path(id: @entity.id))
  else
    render :new, status: :bad_request
  end
end

#destroyObject

delete /photos/:id



40
41
42
43
44
45
# File 'app/controllers/photos_controller.rb', line 40

def destroy
  if @entity.destroy
    flash[:notice] = t('photos.destroy.success')
  end
  redirect_to admin_photos_path
end

#editObject

get /photos/:id/edit



27
28
# File 'app/controllers/photos_controller.rb', line 27

def edit
end

#newObject

get /photos/new



8
9
10
# File 'app/controllers/photos_controller.rb', line 8

def new
  @entity = Photo.new
end

#showObject

get /photos/:id



13
14
# File 'app/controllers/photos_controller.rb', line 13

def show
end

#updateObject

patch /photos/:id



31
32
33
34
35
36
37
# File 'app/controllers/photos_controller.rb', line 31

def update
  if @entity.update(entity_parameters)
    redirect_to admin_photo_path(id: @entity.id), notice: t('photos.update.success')
  else
    render :edit, status: :bad_request
  end
end