Sha256: ba77eefd466e8f0c00c7690610f304170103115f2920c1da84165c7aa10d3e43

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 Bytes

Contents

module IsBot
  module CaptchaInReverse
    def self.included(base)
      base.class_eval do
        extend ClassMethods
        class_attribute :captcha_in_reverse
      end
    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

1 entries across 1 versions & 1 rubygems

Version Path
is_bot-0.3.0 lib/is_bot/is_bot.rb