Class: CommentsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- CommentsController
- Defined in:
- app/controllers/comments_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/comments_controller.rb', line 25 def create @comment = @model.create_comment!(params[:comment]) if @comment.save flash[:notice] = 'Comment was successfully created.' else flash[:error] = 'Comment wasn\'t created.' end respond_with(@model) end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/comments_controller.rb', line 44 def destroy @comment.destroy respond_with(@model) end |
#edit ⇒ Object
21 22 23 |
# File 'app/controllers/comments_controller.rb', line 21 def edit respond_with([@model,@comment]) end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/comments_controller.rb', line 8 def index @comments = @model.comments respond_with([@model,@comments]) end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/comments_controller.rb', line 17 def new respond_with([@model,@comment = Comment.new(:parent => params[:parent])]) end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/comments_controller.rb', line 13 def show respond_with([@model,@comment]) end |
#update ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/comments_controller.rb', line 35 def update if @comment.update_attributes(params[:comment]) flash[:notice] = 'Comment was successfully updated.' else flash[:error] = 'Comment wasn\'t deleted.' end respond_with([@model,@comment], :location => @model) end |