Sha256: 1b014dc053f6e31cdd286e43b42ecdce4ecb852e3e7d1561f229eb3f32bac8cc
Contents?: true
Size: 2 KB
Versions: 1
Compression:
Stored size: 2 KB
Contents
class CommentsController < ApplicationController unloadable before_filter :find_commentable def create raise ActionController::UnknownAction unless @commentable.allow_comments? @comment = @commentable.comments.build(params[:comment]) unless Settings.defensio_api_key.blank? viking_response = viking.check_comment( :user_ip => request.remote_ip, :article_date => @commentable.published_at, :comment_author => @comment.author, :comment_type => 'comment', :comment_content => @comment.comment, :comment_author_email => @comment.email, :user_logged_in => logged_in?, :referrer => request.referer, :permalink => @commentable ) logger.info "VIKING RESPONSE: #{viking_response.inspect}" @comment.spam_filter = !viking_response[:spam] else @comment.spam_filter = true end respond_to do |format| if @comment.save format.html { redirect_to @commentable } format.js format.json { render :json => @comment.to_json(:except => [:commentable_type, :commentable_id ]), :status => :created, :location => permalink(@commentable, :anchor => "comment-#{@comment.id}") } else format.html { render :action => 'new' } format.js format.json { render :json => @comment.errors.full_messages, :status => :unprocessable_entity } end end end protected def find_commentable case when params[:article_id] @commentable = Article.published.find(params[:article_id]) end raise ActionController::UnknownAction if @commentable.nil? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
beef-articles-0.3.7 | app/controllers/comments_controller.rb |