基本上,我尝试在我的应用中使用twitter-bootstrap-rails
和devise
gem。但是,当我尝试rake db:migrate
时,它一直在抱怨黄瓜。黄瓜轨道位于Gemfile中的group :development, :test
下。
我的宝石环境:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.17
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.3.0]
- INSTALLATION DIRECTORY: /Users/user1/.rvm/gems/ruby-1.9.2-p290
- RUBY EXECUTABLE: /Users/user1/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /Users/user1/.rvm/gems/ruby-1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/user1/.rvm/gems/ruby-1.9.2-p290
- /Users/user1/.rvm/gems/ruby-1.9.2-p290@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
我跑rake db:migrate
后,它给了我这条消息:
$ rake --trace db:migrate
WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called.
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant User
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0/lib/active_support/inflector/methods.rb:226:in `block in constantize'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0/lib/active_support/inflector/methods.rb:225:in `each'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0/lib/active_support/inflector/methods.rb:225:in `constantize'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise.rb:293:in `get'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/mapping.rb:77:in `to'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/mapping.rb:72:in `modules'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/mapping.rb:89:in `routes'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/mapping.rb:156:in `default_used_route'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/mapping.rb:66:in `initialize'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise.rb:327:in `new'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise.rb:327:in `add_mapping'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/rails/routes.rb:206:in `block in devise_for'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/rails/routes.rb:205:in `each'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/rails/routes.rb:205:in `devise_for'
/Users/user1/pachamama/config/routes.rb:4:in `block in <top (required)>'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/routing/route_set.rb:272:in `instance_exec'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/routing/route_set.rb:272:in `eval_block'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0/lib/action_dispatch/routing/route_set.rb:249:in `draw'
/Users/user1/pachamama/config/routes.rb:1:in `<top (required)>'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/routes_reloader.rb:40:in `each'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/routes_reloader.rb:16:in `reload!'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0/lib/active_support/file_update_checker.rb:78:in `call'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0/lib/active_support/file_update_checker.rb:78:in `execute'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/routes_reloader.rb:27:in `updater'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application/finisher.rb:67:in `block in <module:Finisher>'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `instance_exec'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `run'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `each'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `run_initializers'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application.rb:136:in `initialize!'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/user1/pachamama/config/environment.rb:5:in `<top (required)>'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application.rb:103:in `require_environment!'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/user1/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/user1/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/user1/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate => environment
答案 0 :(得分:23)
答案 1 :(得分:5)
未在app / models /目录中创建user.rb。这解决了错误(未初始化的常量用户)。黄瓜警告可以通过安德鲁建议
来解决gem 'cucumber-rails', :require => false
或
确保存在features/support/env.rb
,以便在我的设置中执行以下操作:
rails g cucumber:install
rails g cucumber:install capybara
rake cucumber