我试图运行rails服务器但无法运行它并收到此错误消息

时间:2015-02-27 13:26:35

标签: ruby-on-rails

Booting WEBrick
=> Rails 4.1.1 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Exiting
/home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection': 'production' database is not configured. Available: ["development"] (ActiveRecord::AdapterNotSpecified)
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:224:in `resolve_connection'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:152:in `resolve'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:182:in `spec'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_handling.rb:50:in `establish_connection'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:129:in `block (2 levels) in <class:Railtie>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:44:in `each'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/base.rb:23:in `<top (required)>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/relation/predicate_builder.rb:111:in `<class:PredicateBuilder>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/relation/predicate_builder.rb:2:in `<module:ActiveRecord>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record/relation/predicate_builder.rb:1:in `<top (required)>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies/autoload.rb:70:in `block in eager_load!'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies/autoload.rb:70:in `each'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies/autoload.rb:70:in `eager_load!'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.1/lib/active_record.rb:155:in `eager_load!'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/application/finisher.rb:58:in `each'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/application/finisher.rb:58:in `block in <module:Finisher>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `run'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:345:in `each'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:345:in `call'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
        from /tmp/IndiaDataManagement/config/environment.rb:5:in `<top (required)>'
        from /tmp/IndiaDataManagement/config.ru:3:in `require'
        from /tmp/IndiaDataManagement/config.ru:3:in `block in <main>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
        from /tmp/IndiaDataManagement/config.ru:in `new'
        from /tmp/IndiaDataManagement/config.ru:in `<main>'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/server.rb:50:in `app'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/server.rb:69:in `start'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:81:in `block in server'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from /home/ec2-user/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:8:in `require'
        from bin/rails:8:in `<main>'

1 个答案:

答案 0 :(得分:1)

您需要在database.yml文件中正确输入。 例如:

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: prod
  pool: 25
  username: root
  password: abc123