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 http://progressbarhelper.googlecode.com/svn/trunk/progress_bar_helper/

#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)

Example:
<%=custom_static_progress_bar(”a2?,1.0,{:show_text=>”Test”,:animate=>true,:width=>120,:height=>12})%>

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

Njoi A gr8 progress bar.

Thanks

Dhaval Parikh

http://www.dhavalparikh.co.in

Be Sociable, Share!

9 comments

  • Amit

    Hi Dhaval

    when I tried following command – I got error message –

    C:\test\bar\demo>ruby script/plugin install http://progressbarhelper.googlecode.
    com/svn/trunk/progress_bar_helper/

    Plugin not found: [“http://progressbarhelper.googlecode.com/svn/trunk/progress_b
    ar_helper/”]

    Can you check the path?

    Regards
    Amit

  • Hi Amit

    http://progressbarhelper.googlecode.com/svn/trunk/progress_bar_helper/ This is the right path. If you open the url directly you will be able to see all the files. Try again it should work.

    Thanks

  • Amit Patel

    Hi Dhaval,

    I need this for showing file upload progress.
    I am fairly new to rails. Can you please provide me an exmple on how to do this.

    Thanks a lot!!!!!!
    -Amit Patel.
    Software Developer, Rocky Hill, CT.

  • Hi Amit

    The description written here should solve the problem. You just need to install the plugin for the given url, include the js file as mentioned in the description and call it in the view as mentioned in the post. Let me know the exact problem you are facing or the error you are getting and I shall help you out with it.

    Thanks

  • Mathew

    can you tell me this example for file uploading.. i cant able to get exactly what you are trying to say in this line

    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)

    Example:
    ”Test”,:animate=>true,:width=>120,:height=>12})%>

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

    thanks in advance
    mathew vivek

  • Thomas

    Hi Dhaval,
    thank you for your progress bar for rails. I have tried this within redmine and got a very nice bar, but only static. Do you know how I can add the dynamic refresh? I want to show the progress of importing some issues from an xml-file.

    View:

    Controller:
    require ‘action_view/helpers/asset_tag_helper’
    require File.dirname(__FILE__) + ‘/../../../progress_bar_helper/lib/progress_bar_helper’
    include AttributesHelper
    include ProgressBarHelper
    include ActionView::Helpers::AssetTagHelper
    include ActionView::Helpers::TagHelper
    include ActionView::Helpers::AssetTagHelper
    include ActionView::Helpers::JavaScriptHelper

    def view_the_prbar
    @a_value = 0.5 #show me 50%
    end

    Thanks in advance, Thomas

  • Thomas

    View (was not show inside last post): “”

  • shareef

    Hi Dhaval,

    I was installed this plugin in my apps, it was successfully installed but when i put “Test”,:animate=>true,:width=>120,:height=>12})%>
    this code in my view i am getting error undefined method `custom_static_progress_bar’

    actually i want to show the progress bar when i submit the form with documents/videos, so please can you explain briefly….
    Thanks in advance………

Leave a Reply

Your email address will not be published. Required fields are marked *