ruby-on-railsruby-on-rails-3rails-enginesbandit

Uninitialized constant Bandit::Engine


I have a Rails 3.2, Ruby 1.9 app that I'm attempting to setup with the bandit gem.

I've bundled installed the gem, run the bandit:install and modified the bandit.yml to (for development) values of round_robin and memory.

However, all attempts to start the dev server (rails s) result in the following error:

/Users/michaelbuckbee/Sites/bshapp/config/routes.rb:148:in `block in ': uninitialized constant Bandit::Engine (NameError)
    from /Users/michaelbuckbee/.rvm/gems/ruby-1.9.3-p0@bshapp/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
    from /Users/michaelbuckbee/.rvm/gems/ruby-1.9.3-p0@bshapp/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
    from /Users/michaelbuckbee/.rvm/gems/ruby-1.9.3-p0@bshapp/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:260:in `draw'
    from /Users/michaelbuckbee/Sites/bshapp/config/routes.rb:1:in `'

If I remove the Bandit::Engine line from the routes.rb and go into the rails console I can successfully create Bandit Experiments.


Solution

  • I just followed the instructions on the bandit readme and got the same error. The latest tagged version at this time is bandit-0.1.0; this is what bundler will install if you don't specify any options with gem 'bandit'. I suspect you're using the same version. Looking at the source of that version, Bandit::Engine does not exist. It does appear to be included in bandit HEAD, which is on commit 4c552c1efa at this time. Bundling from HEAD fixed the problem for me.

    So, add the following in your Gemfile, bundle install, and retry your server:

    gem 'bandit', :git => "git://github.com/bmuller/bandit.git"