Class: FeatureBox::CommentsController
Instance Method Summary
collapse
#current_ability, #pages_helper, #retrieve_vars
Methods included from Helpers
define_helpers, included
Instance Method Details
#create ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/feature_box/comments_controller.rb', line 7
def create
suggestion =Suggestion.find(params["suggestion_id"])
@comment.text = params["comment"]["text"]
@comment.user = current_user
@comment.suggestion = suggestion
if @comment.save
redirect_to suggestion, notice: 'Comment was successfully added.'
else
redirect_to suggestion, :flash => {
:error => 'Comment cannot be empty'
}
end
end
|
#destroy ⇒ Object
38
39
40
41
|
# File 'app/controllers/feature_box/comments_controller.rb', line 38
def destroy
@comment.destroy
redirect_to @comment.suggestion, notice: 'Comment was successfully deleted.'
end
|
#edit ⇒ Object
22
23
|
# File 'app/controllers/feature_box/comments_controller.rb', line 22
def edit
end
|
#show ⇒ Object
25
26
27
|
# File 'app/controllers/feature_box/comments_controller.rb', line 25
def show
redirect_to @comment.suggestion
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/controllers/feature_box/comments_controller.rb', line 29
def update
@comment.text = params[:comment][:text]
if @comment.save
redirect_to @comment.suggestion, notice: 'Comment was successfully updated.'
else
render action: "edit"
end
end
|