Module: ActsAsTextcaptcha::Textcaptcha
- Defined in:
- lib/acts_as_textcaptcha/textcaptcha.rb
Overview
:nodoc:
Defined Under Namespace
Modules: InstanceMethods Classes: BadResponse
Instance Method Summary (collapse)
Instance Method Details
- (Object) acts_as_textcaptcha(options = nil)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/acts_as_textcaptcha/textcaptcha.rb', line 33 def acts_as_textcaptcha( = nil) cattr_accessor :textcaptcha_config attr_accessor :spam_question, :spam_answers, :spam_answer, :skip_textcaptcha if respond_to?(:accessible_attributes) if accessible_attributes.nil? && respond_to?(:attr_protected) attr_protected :spam_question attr_protected :skip_textcaptcha elsif respond_to?(:attr_accessible) attr_accessible :spam_answer, :spam_answers end end validate :validate_textcaptcha if .is_a?(Hash) self.textcaptcha_config = .symbolize_keys! else begin self.textcaptcha_config = YAML.load(File.read("#{Rails.root ? Rails.root.to_s : '.'}/config/textcaptcha.yml"))[Rails.env].symbolize_keys! rescue raise 'could not find any textcaptcha options, in config/textcaptcha.yml or model - run rake textcaptcha:config to generate a template config file' end end include InstanceMethods end |