Module: ActsAsRecaptcha::Recaptcha
- Defined in:
- lib/acts_as_recaptcha/acts_as_recaptcha.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
Instance Method Details
#acts_as_recaptcha(options = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/acts_as_recaptcha/acts_as_recaptcha.rb', line 4 def acts_as_recaptcha( = nil) cattr_accessor :recaptcha_config attr_accessor :recaptcha_answer, :recaptcha_challenge, :skip_recaptcha, :recaptcha_remote_ip if respond_to?(:accessible_attributes) if accessible_attributes.nil? attr_protected :skip_recaptcha else attr_accessible :recaptcha_answer, :recaptcha_challenge, :recaptcha_remote_ip end end validate :validate_recaptcha if .is_a?(Hash) self.recaptcha_config = .symbolize_keys! else begin self.recaptcha_config = YAML.load(File.read("#{Rails.root ? Rails.root.to_s : '.'}/config/recaptcha.yml"))[Rails.env].symbolize_keys! rescue raise 'could not find any recaptcha options, in config/recaptcha.yml or model' end end include InstanceMethods end |