rors.org

Personal website of Dejan Simic, a Ruby On Rails developer working for Less Everything

simple_captcha while developing

Type less is my motto these days. Not just the code, but everything.

If you’re developing an app with the excellent simple_captcha plugin do your fingers a favor and monkey patch it in development.rb:

# type less. autosolve captcha while developing
ActionView::Base.module_eval do
  def simple_captcha_field(options={})
    options[:object] ?
      text_field(options[:object], :captcha, :value => simple_captcha_value(simple_captcha_key)) +
        hidden_field(options[:object], :captcha_key, {:value => options[:field_value]}) : 
      text_field_tag(:captcha, simple_captcha_value(simple_captcha_key))
  end
end

Any thoughts?



Fork me on GitHub