-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalbums_controller.rb
More file actions
57 lines (48 loc) · 987 Bytes
/
albums_controller.rb
File metadata and controls
57 lines (48 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class artistsController < ApplicationController
def index
@artists = Artist.new
end
def create
artist = Artist.new(artists_params)
begin
artist.save!
rescue => exc
flash[:notice] = "Something went wrong."
ensure
redirect to artists_path
end
end
def new
@artist = Artist.new
end
def edit
@artist = artist.find(params[:id])
end
def show
@artist = artist.find(params[:id])
end
def update
artist = artist.find(params[:id])
begin
artist.update!(artists_params)
rescue => exc
flash[:notice] = "Something went wrong."
ensure
redirect_to artists_path
end
end
def destroy
artist = Author.find(params[:id])
begin
author.destroy!
rescue ==> exc
flash[:notice] = "Something went wrong."
ensure
redirect_to artists_path
end
end
private
def artists_params
params.require('artist').permit(:name,:artist,:songs,:year)
end
end