Class: CommentsController
Instance Method Summary
collapse
included
#current_ability
#parent, #voluntary_application_javascripts, #voluntary_application_repository_path, #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
@comment = Comment.new(params[:comment])
@comment.user_id = current_user.id
if @comment.save
redirect_to @comment., 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
@comment = Comment.find(params[:id])
@comment.destroy
redirect_to , notice: t('general.form.destroyed')
end
|
#edit ⇒ Object
34
35
36
|
# File 'app/controllers/comments_controller.rb', line 34
def edit
@comment = Comment.find(params[:id])
end
|
#index ⇒ Object
10
11
12
|
# File 'app/controllers/comments_controller.rb', line 10
def index
@comments = Comment.includes(:commentable, :user).all
end
|
#new ⇒ Object
18
19
20
21
|
# File 'app/controllers/comments_controller.rb', line 18
def new
@comment = Comment.new(params[:comment])
@comment. = @commentable
end
|
#resource ⇒ Object
54
55
56
|
# File 'app/controllers/comments_controller.rb', line 54
def resource
@comment
end
|
#show ⇒ Object
14
15
16
|
# File 'app/controllers/comments_controller.rb', line 14
def show
@comment = Comment.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
@comment = Comment.find(params[:id])
if @comment.update_attributes(params[:comment])
redirect_to @comment., notice: t('general.form.successfully_updated')
else
render :edit
end
end
|