Class: AlbumsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

post /albums



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

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

#destroyObject

delete /albums/:id



41
42
43
44
45
46
# File 'app/controllers/albums_controller.rb', line 41

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

#editObject

get /albums/:id/edit



28
29
# File 'app/controllers/albums_controller.rb', line 28

def edit
end

#newObject

get /albums/new



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

def new
  @entity = Album.new
end

#showObject

get /albums/:id



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

def show
  @collection = @entity.photos.page_for_visitors(current_page)
end

#updateObject

patch /albums/:id



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

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