Sha256: d99cb4bdd848609c0fdca4b3288a82402a6d33949762a16911e1bfb6579be29e
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require_dependency "almanac/application_controller" module Almanac class CommentsController < ApplicationController load_and_authorize_resource class: Almanac::Comment respond_to :html def create @comment = Comment.new(params[:comment]) @post = Post.find(params[:post_id]) @comment.post = @post respond_with(@comment) do |format| @comment.spam = (@blog.rakismet_key?) ? @comment.spam? : false if @comment.save format.html { redirect_to post_path(@post.slug), :notice => (@comment.spam) ? "Your comment looks like spam, it won't be published." : "Comment was successfully posted." } else format.html { redirect_to post_path(@post.slug), :alert => 'Something went wrong, try again.' } end end end def destroy @post = Post.find(params[:post_id]) @comment = Comment.find(params[:id]) respond_to do |format| if @comment.destroy format.html { redirect_to post_path(@post), :notice => 'Comment was successfully deleted.' } format.js { render :nothing => true } else format.html { redirect_to post_path(@post), :alert => 'Something went wrong, try again.' } end end end def spam @blog = Blog.first @comments = Comment.spam respond_with(@comments) do |format| end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
almanac-0.8.0 | app/controllers/almanac/comments_controller.rb |