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