Class: AlbumsController
Constant Summary
ControllerCallbacks::METHODS
Instance Attribute Summary
#params, #req, #res
Instance Method Summary
collapse
#current_user, #ensure_login, #ensure_logout, #logged_in?, #login, #logout
#form_authenticity_token, #initialize, #invoke_action, #link_to, protect_from_forgery, #root_url
#before_action
Constructor Details
This class inherits a constructor from ControllerBase
Instance Method Details
#create ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/scaffold/app/controllers/albums_controller.rb', line 14
def create
@album = Album.new(album_params)
if @album.save
redirect_to album_url(@album)
else
@band = @album.band
flash.now[:errors] = @album.errors
render :new
end
end
|
#destroy ⇒ Object
42
43
44
45
46
|
# File 'lib/scaffold/app/controllers/albums_controller.rb', line 42
def destroy
@album = Album.find(params[:id])
@album.destroy
redirect_to band_url(@album.band_id)
end
|
#edit ⇒ Object
26
27
28
29
|
# File 'lib/scaffold/app/controllers/albums_controller.rb', line 26
def edit
@album = Album.find(params[:id])
render :edit
end
|
#new ⇒ Object
8
9
10
11
12
|
# File 'lib/scaffold/app/controllers/albums_controller.rb', line 8
def new
@band = Band.find(params[:band_id])
@album = Album.new(band_id: params[:band_id])
render :new
end
|
#show ⇒ Object
3
4
5
6
|
# File 'lib/scaffold/app/controllers/albums_controller.rb', line 3
def show
@album = Album.find(params[:id])
render :show
end
|
#update ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/scaffold/app/controllers/albums_controller.rb', line 31
def update
@album = Album.find(params[:id])
if @album.update_attributes(album_params)
redirect_to album_url(@album)
else
flash.now[:errors] = @album.errors
render :edit
end
end
|