Progress Bar in Rails

Ever thought of implementing a progress bar in rails? or did a need arise for you to do the same?

Something like if you want the user to show the progress bar while he is uploading the file and so on

Well there is a plugin available which will help you to do the same.. Here are the details for it

ProgressBar Plugin:

Install: ruby script/plugin install

#View –

Include JS Files
<%=javascript_include_tag “progress_bar/jsProgressBarHandler.js”%>

Custom Static Progress Bar:
custom_static_progress_bar(name, value, options = {})

Options are:
# * name : used as an id for the progress bar
# * value : decimal value to represent (i.e. value <= 1)
# * options : rendering options
# Rendering options are:
# * show_text : set to true to display percentage value in a text form
# * animate : set to true to animate the image
# * width : sets the width of the image (!must be the same as the actual box_image width
# * height : sets the height of the image (!must be the same as the actual box_image height
# * box_image : sets the container image
# * bar_images : sets the progress bar images (must be an Array)


Progress Bar:
progress_bar(name,value, display_percentage_text = false, multicolor = false)

Njoi A gr8 progress bar.


Dhaval Parikh

Be Sociable, Share!

.htaccess protection with nginx

Hey just recently had a requirement where in I had to set password for my website. It was a ruby on rails website and I had to set .htaccess for it. I knew how to setup .htaccess for apache but with nginx (that our site was using as webserver) I didnt knew what to do.

Then I figured out the solution

Open nginx.conf file. Search for the location word you might see multiple location configuration. But put the code below in the root location

            auth_basic "RESTRICTED ACCESS";
            auth_basic_user_file /path/to/htpasswd/file

For ruby on rails it will be generally in
 the public folder of your rails app.

If you havent generated the htpassword 
yet pls do it using the following command 

htpasswd -b -c htpasswd username password

Hope this will be useful to you if you
 are caught in the same situation as me.

Njoi protecting the site
Be Sociable, Share!

Spam filtering in rails using Akismet

SPAM!!!! is a very big problem for all big applications. If you are having a site which allows users to comment on ur posts and so on then you might get affected by spamming.

Akismet is something which is helping us to avoid spamming on our sites.

There is a rails plugin available at

You can download this and configure akismet in your rails app. more information is provided in read me file of the plugin.

IF you want to see the actual implementation you can watch a screencast on

Hope this is some useful information for you.

Be Sociable, Share!

Counter Cache in rails 2.1

Counter cache is really an important feature in rails 2.1 . This method is really helpful when u want to keep a count on something and avoid firing sql query every time which results in more processing times.

Here it goes

To activate this feature, you need to take two simple steps. First, add the
option :counter_cache to the belongs_to declaration in the child table.

class LineItem < counter_cache =””> true

Second, in the definition of the parent table (products in this example) you
need to add an integer column whose name is the name of the child table with
_count appended.

create_table :products, :force => true do |t|
t.column :title, :string
t.column :description, :text
# …
t.column :line_items_count, :integer, :default => 0

Thats it .. Counter cache is enabled now.

Be Sociable, Share!

Page Screenshot in Rails

Have you ever been through a situation where you need to embed a Flash object or some other element in a pdf file which cant be done directly? There is gr8 solution for it

with the help or combination of RMagick + Image Magick + win32Screenshot gem you can take the screenshot of the desktop or webpage and generate an image from it and eventually embed it in your pdf file

Here is the code for it

require 'win32screenshot'
require 'RMagick'
def screenCapture
  width, height, bitmap = Win32::Screenshot.desktop
  img_lst =

If you are stuck any where just write to me or post a comment hereI would be pleased to solve your error
Be Sociable, Share!

Flex On rails

Hi all

With the increasing number of sites being made in RIA – Rich Internet Applications many people have adopted Rails + Flex for make a Rich Internet Application.

There is a very gr8 plugin or code available on known as ruby on rails ria sdk by adobe. Here is the url for it

The Ruby on Rails RIA SDK by Adobe provides developers with samples and code to help develop solutions with Ruby and Adobe technologies. The SDK includes open source code created by third parties as well as samples and demos that have been created by project members.

You can download an initial .zip file containing all the files using the Download link on the right hand side, or you can check out the code via SVN by clicking on the ‘Source’ tab on the top of the page.

This will help you to get things going and working with Rails + Adobe technology.

Hope this helps


Dhaval Parikh
Software Engineer
Ruby on Rails

Be Sociable, Share!
1 2 3 4