2015-12-16 65 views
0

全新安装rails 4.2.4和ruby 2.2.3。每次尝试启动服务器时,都会遇到此错误。我也在下面发布了我的development.rb文件。在我的ROR安装中似乎出现了一些麻烦,但我无法弄清楚它是什么。有任何想法吗?多谢你们!引导Rails服务器问题

Exiting 
/Users/Rick/Desktop/RevMatchSite/forum_searcher/config/environments/development.rb:32:in fetch: key not found (KeyError) 
from /Users/Rick/Desktop/RevMatchSite/forum_searcher/config/environments/development.rb:32:in block in <top (required)> 
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/railtie.rb:210:in instance_eval 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/railtie.rb:210:in configure 
    from /Users/Rick/Desktop/RevMatchSite/forum_searcher/config/environments/development.rb:1:in <top (required)> 
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in require 
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in block in require 
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in load_dependency 
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in require 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:598:in block (2 levels) in <class:Engine> 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:597:in each 
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/engine.rb:597:in block in <class:Engine> 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in instance_exec 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in run 
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in block in run_initializers 
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:150:in block in tsort_each 
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:183:in block (2 levels) in each_strongly_connected_component 
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:210:in block (2 levels) in each_strongly_connected_component_from 
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:219:in each_strongly_connected_component_from 
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:209:in block in each_strongly_connected_component_from 
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in each 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in tsort_each_child 
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:203:in each_strongly_connected_component_from 
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:182:in block in each_strongly_connected_component 
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:180:in each 
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:180:in each_strongly_connected_component 
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tsort.rb:148:in tsort_each 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in run_initializers 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/application.rb:352:in initialize! 
from /Users/Rick/Desktop/RevMatchSite/forum_searcher/config/environment.rb:5:in <top (required)> 
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in require 
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in block in require 
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in load_dependency 
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in require 
    from /Users/Rick/Desktop/RevMatchSite/forum_searcher/config.ru:3:in block in <main> 
from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in instance_eval 
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in initialize 
    from /Users/Rick/Desktop/RevMatchSite/forum_searcher/config.ru:in new 
from /Users/Rick/Desktop/RevMatchSite/forum_searcher/config.ru:in <main> 
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in eval 
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in new_from_string 
from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in parse_file 
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:299:in build_app_and_options_from_config 
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:208:in app 
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands/server.rb:61:in app 
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/server.rb:336:in wrapped_app 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands/server.rb:139:in log_to_stdout 
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands/server.rb:78:in start 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in block in server 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in tap 
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in server 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in run_command! 
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in <top (required)> 
from /Users/Rick/Desktop/RevMatchSite/forum_searcher/bin/rails:8:in require 
    from /Users/Rick/Desktop/RevMatchSite/forum_searcher/bin/rails:8:in <top (required)> 
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.4.0/lib/spring/client/rails.rb:28:in load 
from /Library/Ruby/Gems/2.0.0/gems/spring-1.4.0/lib/spring/client/rails.rb:28:in call 
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.4.0/lib/spring/client/command.rb:7:in call 
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.4.0/lib/spring/client.rb:28:in run 
from /Library/Ruby/Gems/2.0.0/gems/spring-1.4.0/bin/spring:49:in <top (required)> 
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.4.0/lib/spring/binstub.rb:11:in load 
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.4.0/lib/spring/binstub.rb:11:in <top (required)> 
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in require 
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in require 
    from /Users/Rick/Desktop/RevMatchSite/forum_searcher/bin/spring:16:in <top (required)> 
from bin/rails:3:in load 
    from bin/rails:3:in <main> 

几个人请我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 = false 

    # 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 = false 

    config.action_mailer.default_url_options = { host: 'localhost', port: 3000} 
    config.action_mailer.smtp_settings = { 
    address: ENV.fetch("SMTP_ADDRESS"), 
    authentication: :plain, 
    domain: ENV.fetch("SMTP_DOMAIN"), 
    enable_starttls_auto: true, 
    password: ENV.fetch("SMTP_PASSWORD"), 
    port: "587", 
    user_name: ENV.fetch("SMTP_USERNAME") 
    } 
    config.action_mailer.default_url_options = { host: ENV["SMTP_DOMAIN"] } 
    # config.action_mailer.raise_delivery_errors = true 
    # config.action_mailer.perform_deliveries = true 
    # config.action_mailer.delivery_method = :smtp 
    config.active_record.raise_in_transactional_callbacks = 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 

    # Raises error for missing translations 
    # config.action_view.raise_on_missing_translations = true 
end 
+0

你可以在这里粘贴你的'config/environments/development.rb'文件吗? – Mareq

+0

请显示您的'config/environment/development.rb'文件 – BroiSatse

+0

此行生成的错误:/config/environments/development.rb:32: – Elvn

回答

0

方法fetch需要密钥的存在,只是它取代简单的括号:

config.action_mailer.smtp_settings = { 
    address: ENV["SMTP_ADDRESS"], 
    authentication: :plain, 
    domain: ENV["SMTP_DOMAIN"], 
    enable_starttls_auto: true, 
    password: ENV["SMTP_PASSWORD"], 
    port: "587", 
    user_name: ENV["SMTP_USERNAME"] 
} 

对于不存在的键返回nil。当然,如果你不想定义那个配置选项。