rakismet icon indicating copy to clipboard operation
rakismet copied to clipboard

Problem when validating extra attributes

Open kathirvelkg opened this issue 8 years ago • 1 comments

I am using Rakismet(1.5.3) gem in my Rails(3.2.22) project. Rakismet validates attributes such as author, author_email, author_url, content by default.

My question: I want to validate extra columns in model like post tile, post summary, post content.I tried to merge the post title, post content and post summary and assigned to content field.

post.rb

class Post < ActiveRecord::Base
  include Rakismet::Model
  belongs_to :user

  rakismet_attrs  :author => proc { user.full_name }, 
                           :author_email => proc { user.email }
                           :content => :post_detail

  #Virtual attribute
  def post_detail
    "#{title} #{summary} #{content}"
  end
end

It didn't work as expected viz didn't throw any spam errors even though title, content and summary had spam text(viagra-test-123). I have also tried Proc :content => proc { "#{title} #{summary} #{content}" }, but no result.

It is working only when we assign title/summary separately to rakismet's content attribute as :content => :title

kathirvelkg avatar Jan 05 '17 08:01 kathirvelkg

There's a section on debugging responses in the docs. The only guaranteed way to trigger a spam response is to set comment_author to viagra-test-123. Adding that string to the :content field isn't guaranteed to produce a positive result.

If you think Akismet really isn't properly validating your content, you'll need to speak with them. This gem is just a bridge to their API :)

joshfrench avatar Apr 19 '17 16:04 joshfrench