Class: CommentsController
Instance Method Summary
collapse
included
#current_ability
#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets
included
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/comments_controller.rb', line 23
def create
= .new(params[:comment])
.user_id = current_user.id
if .save
redirect_to ., notice: t('general.form.successfully_created')
else
render :new
end
end
|
#destroy ⇒ Object
48
49
50
51
52
|
# File 'app/controllers/comments_controller.rb', line 48
def destroy
= .find(params[:id])
.destroy
redirect_to , notice: t('general.form.destroyed')
end
|
#edit ⇒ Object
34
35
36
|
# File 'app/controllers/comments_controller.rb', line 34
def edit
= .find(params[:id])
end
|
#index ⇒ Object
10
11
12
|
# File 'app/controllers/comments_controller.rb', line 10
def index
= .includes(:commentable, :user).all
end
|
#new ⇒ Object
18
19
20
21
|
# File 'app/controllers/comments_controller.rb', line 18
def new
= .new(params[:comment])
. =
end
|
#resource ⇒ Object
54
55
56
|
# File 'app/controllers/comments_controller.rb', line 54
def resource
end
|
#show ⇒ Object
14
15
16
|
# File 'app/controllers/comments_controller.rb', line 14
def show
= .includes(:commentable, :user).find(params[:id])
end
|
#update ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/comments_controller.rb', line 38
def update
= .find(params[:id])
if .update_attributes(params[:comment])
redirect_to ., notice: t('general.form.successfully_updated')
else
render :edit
end
end
|