Sha256: f1bca743dbffb54d4d75e74cbacdd4802d493daecbfc72169fdd0187f25cac5f

Contents?: true

Size: 716 Bytes

Versions: 5

Compression:

Stored size: 716 Bytes

Contents

module IsBot
  module CaptchaInReverse
    extend ActiveSupport::Concern

    included do 
      class_attribute :captcha_in_reverse
    end

    module ClassMethods
      def validate_captcha(options = {})
        validates_each :captcha_in_reverse do |record, attr, value|
          record.errors[attr] << (options[:message] || "You are a bot!") unless value.blank?
        end
      end
    end
  end

  module ViewHelper
    def captcha_reverse_field(object, options={})
      style = (options.delete(:style) || '') << ";"
      style << "display: none;"
      ActionView::Helpers::InstanceTag.new(object, :captcha_in_reverse, self).to_input_field_tag("text", options.merge(:style => style) )
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
is_bot-1.0.0 lib/is_bot/is_bot.rb
is_bot-0.3.6 lib/is_bot/is_bot.rb
is_bot-0.3.5 lib/is_bot/is_bot.rb
is_bot-0.3.2 lib/is_bot/is_bot.rb
is_bot-0.3.1 lib/is_bot/is_bot.rb