Sha256: 87b89dd8a6c929987c1544b1b1ead4a4b887ed011631f0e61cca9be268cff5f9

Contents?: true

Size: 1.06 KB

Versions: 20

Compression:

Stored size: 1.06 KB

Contents

class CommentsController < ApplicationController
  def index
    @comments = Comment.all
  end

  def show
    @comment = Comment.find(params[:id])
  end

  def new
    @comment = Comment.new
  end

  def edit
    @comment = Comment.find(params[:id])
  end

  def vote
    @comment = Comment.find(params[:id])
    @comment.votes += params[:value].to_i
    @comment.save
    redirect_to(comments_url, :notice => 'Vote added!')
  end

  def create
    @comment = Comment.new(comment_params)
    if @comment.save
      redirect_to(@comment, :notice => 'Comment was successfully created.')
    else
      render "new"
    end
  end

  def update
    @comment = Comment.find(params[:id])
    if @comment.update(comment_params)
      redirect_to(@comment, :notice => 'Comment was successfully updated.')
    else
      render "edit"
    end
  end

  # DELETE /comments/1
  # DELETE /comments/1.xml
  def destroy
    @comment = Comment.find(params[:id])
    @comment.destroy
    redirect_to(comments_url)
  end

  private

  def comment_params
    params.require(:comment).permit!
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
merit-4.0.3 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.12 test/dummy/app/controllers/comments_controller.rb
merit-4.0.2 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.11 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.10 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.09 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.08 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.07 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.06 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.05 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.04 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.03 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.02 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.01 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.5.00 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.0.4 test/dummy/app/controllers/comments_controller.rb
qalam_merit-4.0.35 test/dummy/app/controllers/comments_controller.rb
merit-4.0.1 test/dummy/app/controllers/comments_controller.rb
merit-4.0.0 test/dummy/app/controllers/comments_controller.rb
merit-3.0.3 test/dummy/app/controllers/comments_controller.rb