Class: Discussion::CommentsController
- Inherits:
-
InheritedResources::Base
- Object
- InheritedResources::Base
- Discussion::CommentsController
- Defined in:
- app/controllers/discussion/comments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/discussion/comments_controller.rb', line 24 def create build_resource respond_to do |format| if @comment.save format.html { redirect_to :back } format.js { collection } format.json { render json: @comment, status: :created, location: @comment } else format.html { render action: "new" } format.json { render json: @comment.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/controllers/discussion/comments_controller.rb', line 50 def destroy @comment.destroy respond_to do |format| format.html { redirect_to :back } format.js { collection } format.json { head :no_content } end end |
#edit ⇒ Object
21 22 |
# File 'app/controllers/discussion/comments_controller.rb', line 21 def edit end |
#index ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/discussion/comments_controller.rb', line 10 def index @comments = collection respond_with(@comments) @comments.each { |c| c.read_by!(current_user) } end |
#new ⇒ Object
16 17 18 19 |
# File 'app/controllers/discussion/comments_controller.rb', line 16 def new build_resource respond_with(@comment) end |
#update ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/discussion/comments_controller.rb', line 38 def update respond_to do |format| if @comment.update_attributes(params[:comment]) format.html { redirect_to @comment, notice: 'comment was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @comment.errors, status: :unprocessable_entity } end end end |