Class: BandsController
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
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 19
def create
@band = Band.new(band_params)
if @band.save
redirect_to band_url(@band)
else
flash.now[:errors] = @band.errors.full_messages
render :new
end
end
|
#destroy ⇒ Object
45
46
47
48
49
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 45
def destroy
@band = Band.find(params[:id])
@band.destroy
redirect_to bands_url
end
|
#edit ⇒ Object
30
31
32
33
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 30
def edit
@band = Band.find(params[:id])
render :edit
end
|
#index ⇒ Object
4
5
6
7
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 4
def index
@bands = Band.all
render :index
end
|
#json ⇒ Object
51
52
53
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 51
def json
@bands = Band.all
end
|
#new ⇒ Object
14
15
16
17
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 14
def new
@band = Band.new
render :new
end
|
#show ⇒ Object
9
10
11
12
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 9
def show
@band = Band.find(params[:id])
render :show
end
|
#update ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/scaffold/app/controllers/bands_controller.rb', line 35
def update
@band = Band.find(params[:id])
if @band.update_attributes(band_params)
redirect_to band_url(@band)
else
flash.now[:errors] = @band.errors.full_messages
render :edit
end
end
|