Experiencing Simple_Captcha for Rails 3

A while ago, I was looking for a plugin that working for Rails 3. When I searched the internet, I found simple_captcha and I tried it. My first experience using it was bad. I followed the instruction in https://github.com/galetahub/simple-captcha but I failed, the image code wouldn’t show. I almost frustrated until I found it myself. The key was I combined the instruction from the original site with the article I found at http://blog.brijeshshah.com/simple-captcha-in-rails-3/.

I won’t specify the detail of  how to use simple_captcha here, I just want to share how to establish it on your code. Here’s the step :

  1. Run this command : rails plugin install https://github.com/galetahub/simple-captcha.git
  2. Put this code on your Gemfile : gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git'
  3. Run bundle install command
  4. Run this command : rails generate simple_captcha
  5. Then run this command : rake db:migrate
  6. (I chose to add simple_captcha with controller based) Add this code in your application_controller.rb : include SimpleCaptcha::ControllerHelpers
  7. In your form tag, put this code in : <%= show_simple_captcha(:label => 'Please enter code...') %>

The rest, you can follow the instruction from the original page or the other article that I mentioned earliear.



2 thoughts on “Experiencing Simple_Captcha for Rails 3

  1. Great, salam kenal Pak. Saya coba di ruby 1.8.7, rails 3.0.3, phusion passenger, dapet error kyk gini :
    You can stop Phusion Passenger Standalone by pressing Ctrl-C.
    [ pid=20501 thr=-608395048 file=utils.rb:176 time=2011-04-15 11:22:07.614 ]: *** Exception RuntimeError in PhusionPassenger::Rack::ApplicationSpawner (“simple-captcha” is a Railtie/Engine and cannot be installed as a plugin) (process 20501, thread #):
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/plugin.rb:87
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec’

    Kira-kira bisa bantu analisa masalahnya kenapa ??? thx

    1. Kalau boleh tau, mas agung menambahkan code gem-nya ga di Gemfile?

      Saya waktu itu pernah mendapat error yang serupa (saya juga menggunakan passenger), tapi itu karena saya waktu itu hanya menginstall plugin-nya saja. Setelah saya daftarkan gem-nya di Gemfile saya, semuanya berjalan lancar lagi.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s