Evgenii
Evgenii

Reputation: 37339

How can I use ruby-progressbar in Rails?

I want to use ruby-progressbar in Rails 3.2.11 for my console scripts. I added gem 'ruby-progressbar' to Gemfile and ran bundle install.

It shows uninitialized constant ProgressBar when I try to use it.

If I do require 'ruby-progressbar' it shows the following error:

LoadError: cannot load such file -- ruby-progressbar from /Users/evgenyneu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'

Upvotes: 2

Views: 1810

Answers (1)

Serhii Ovcharenko
Serhii Ovcharenko

Reputation: 75

gem : https://rubygems.org/gems/ruby-progressbar

You need write some as:

require 'progressbar'
pbar = ProgressBar.new('data processing', some_long_data_array.length)
some_long_data_array.each do |data|
  data.process 
  pbar.inc
end
pbar.finish

Upvotes: 2

Related Questions