简体   繁体   中英

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.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM