Rails服务器未运行未知错误

时间:2015-11-18 04:32:08

标签: ruby-on-rails ruby

这是我尝试启动rails服务器时显示的错误 我使用rails 4.2.4.,ruby版本是2.2.1p85。 我是rails的新手,所以告诉我该怎么做

/home/techbirds/Downloads/boxroom-master/config/environments/development.rb:42:in `block in <top (required)>': undefined local variable or method `settings' for #<Boxroom::Application:0x00000002785a80> (NameError)
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/railtie.rb:210:in `instance_eval'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/railtie.rb:210:in `configure'
    from /home/techbirds/Downloads/boxroom-master/config/environments/development.rb:1:in `<top (required)>'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:598:in `block (2 levels) in <class:Engine>'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:597:in `each'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/engine.rb:597:in `block in <class:Engine>'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `call'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
    from /home/techbirds/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
    from /home/techbirds/Downloads/boxroom-master/config/environment.rb:5:in `<top (required)>'
    from /home/techbirds/Downloads/boxroom-master/config.ru:3:in `require'
    from /home/techbirds/Downloads/boxroom-master/config.ru:3:in `block in <main>'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
    from /home/techbirds/Downloads/boxroom-master/config.ru:in `new'
    from /home/techbirds/Downloads/boxroom-master/config.ru:in `<main>'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:61:in `app'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:139:in `log_to_stdout'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:78:in `start'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /home/techbirds/.rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:8:in `require'
    from bin/rails:8:in `<main>'

1 个答案:

答案 0 :(得分:0)

用这个

替换你的development.rb
Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = true

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
   config.assets.raise_runtime_errors = true
   config.action_mailer.default_url_options = {host: "localhost:3000"}
   config.action_mailer.perform_deliveries = true

   config.action_mailer.smtp_settings = {
      :address              => "",
      :port                 => 587,
      # :domain               => ".com",
      :user_name            => "your user name",
      :password             => "your password",

      :authentication       => :plain,
     # :enable_starttls_auto => true
  }
  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end

gmail设置的示例代码

config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => "mydomain.net",
:user_name => "mygmailusername@gmail.com",
:password => "myGmailPassword",
:authentication => "plain",
:enable_starttls_auto => true

}