Populate data

Hello guys,

Let’s take a look below situations:

  • During development mode many times we run command “rake db:migrate VERSION=0” (so all data will be lost!)
  • Our rails application is ready to run and we give it someone to test it. (without data???)
  • Client wants that developer will test on his test data so both can understand it very well. (will developer enter data manually?)

In above all situations we want development data again(of course easily! ). How can we get it? There are some options for this given below:

Seeds is nice option but it will be boring to write all data and populator and faker gem will populate fake data not development data.

So now what to do?

Let’s introduce yaml_db!!!

It’s very easy to use.

  • Install yaml_db as a plugin or gem
  • If you want to give your development data to someone else then run command “rake db:data:dump”
  • This command will create one file named “data.yml” at RAILS_ROOT/db folder. This file contains your all development data.
  • Now if someone wants to use this file then user will put this file at above location and will run command “rake db:data:load”
  • So development database will populate with all data and that’s it!

Isn’t it simple then you thought?

Generate Reports, Graphs, and Documents with Ruby on Rails

Hi guys,

I am sure that you see sometimes various graphs and charts on sites.

Have you ever think to integrate those type of beautiful graphs and charts with your Ruby on Rails sites?

I found some gems and a plugin that can fulfill your wish.

  • Gruff: This gem is very good and very old. So you can find very much info. about it. I suggest you to read book “Practical Reporting with Ruby and Rails: Create and present attractive reports, graphs, and documents using Ruby on the Web, on the desktop, and on the server by David Berube

    For online help please visit http://nubyonrails.com/pages/gruff

  • Scruffy: This gem can be your second choice if you don’t like Gruff. To know much about it please visit http://scruffy.rubyforge.org/
  • Open Flash Chart 2: This plugin is the best that I found till now for creating graphs and charts. To know more about it please go through http://pullmonkey.com/projects/open_flash_chart2/

Please keep in mind that above two gems will create image and Open Flash Chart 2 plugin will create Flash Object so you are supposed to deal with .swf file. But Don’t scare if you don’t know much about it because you can find online free source on it’s  site.

Simple Captcha in Rails Application


Today I will tell you about Captcha.

You must saw different kinds of captcha on the registration page.Well that is for security purpose so any hacker can’t create fake users using any program or script.This is very serious problem on the website.But the solution is much simpler.


Now, which is the best option to implement captcha in rails?

I found a plugin for captcha named “Simple Captcha”.It has quality same as it’s name.It’s damn easy and you supposed to add only one line of code in your view file(Yes!!! Only one line of code. Believe me!)

You can find it here: http://expressica.com/simple_captcha

After installing this plugin write only one line in view file as below:

<%= show_simple_captcha %>

That’s it.

Keep in mind that to use this plugin you have to install RMagick first.
To know more about RMagick click here: http://rmagick.rubyforge.org

You can do custom changes as per your requirements in the plugin.Go through readme file for more details.

So add captcha in your application and have a safe application!

Currency Converter

Hi Guys,

Some days before in my project there was a requirement for currency converter.

I did RND and found only one good plugin for it.

It works fine in my application so it is reliable. (though it is little bit slow as it fetches latest currency rate from the net everytime you make a request.)

The name of plugin is cash_handler.

You can find it here: http://jamesbrooks.net/2009/01/05/rails-cash-handler-plugin/

Believe me it’s very easy to implement and best one.

It provides also facility to update currency rates as you want after some specific time.

by Default it is 24 Hours.

Don’t forget to install hpricot gem before installing this plugin.

So Use this plugin and contact me if you have any problems or suggestions.

Have a Great Day!!!