Rails命令无法正常工作,构建Web应用程序

时间:2015-02-03 00:25:54

标签: ruby-on-rails ruby devise terminal

每次在终端中运行rails s时,都会出现以下文字。

yonas@yonas:~/Documents/code/MCtut/commandsapp$ rails s
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/home/yonas/Documents/code/MCtut/commandsapp/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError)
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:652:in `block in load_config_initializer'
  from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:166:in `instrument'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:651:in `load_config_initializer'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in `each'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in `block in <class:Engine>'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:in `each'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:in `tsort_each_child'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:411:in `call'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:345:in `each'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:345:in `call'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
  from /usr/local/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
  from /home/yonas/Documents/code/MCtut/commandsapp/config/environment.rb:5:in `<top (required)>'
  from /home/yonas/Documents/code/MCtut/commandsapp/config.ru:3:in `require'
  from /home/yonas/Documents/code/MCtut/commandsapp/config.ru:3:in `block in <main>'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
  from /home/yonas/Documents/code/MCtut/commandsapp/config.ru:in `new'
  from /home/yonas/Documents/code/MCtut/commandsapp/config.ru:in `<main>'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:49:in `eval'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:49:in `new_from_string'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:40:in `parse_file'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:299:in `build_app_and_options_from_config'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:208:in `app'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:61:in `app'
  from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:336:in `wrapped_app'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:139:in `log_to_stdout'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:78:in `start'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:80:in `block in server'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
  from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'

1 个答案:

答案 0 :(得分:0)

您错过了计算机上的devise gem。检查devise中是否有Gemfile,如果没有添加:

# in Gemfile
gem 'devise'

之后运行bundler来安装所有应用的依赖项:

$ bundle install