尝试启动Rails服务器时出现问题

时间:2014-04-12 01:37:58

标签: ruby-on-rails ruby macos osx-mavericks

很抱歉,如果这是一个糟糕的问题,我正在尝试初步设置Rails,所以我真的不知道我在做什么。在我正在关注的教程中,它指的是运行“rails服务器”,但是这会返回一些意想不到的结果。(见下文)

Macbookpro:First Cameron$ sudo rails server
Password:
=> Booting WEBrick
=> Rails 4.1.0 application starting in development 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
/Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `action_mailer' for #<Rails::Application::Configuration:0x007fea90b47760> (NoMethodError)
    from /Users/admin/Rails/First/config/environments/development.rb:17:in `block in <top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/railtie.rb:210:in `instance_eval'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/railtie.rb:210:in `configure'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/railtie.rb:182:in `configure'
    from /Users/admin/Rails/First/config/environments/development.rb:1:in `<top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `block in require'
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/engine.rb:594:in `block (2 levels) in <class:Engine>'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/engine.rb:593:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/engine.rb:593:in `block in <class:Engine>'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `instance_exec'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/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.1.0/lib/rails/initializable.rb:44:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/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.1.0/lib/rails/initializable.rb:54:in `run_initializers'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/application.rb:288:in `initialize!'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/railtie.rb:194:in `public_send'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/railtie.rb:194:in `method_missing'
    from /Users/admin/Rails/First/config/environment.rb:5:in `<top (required)>'
    from /Users/admin/Rails/First/config.ru:3:in `require'
    from /Users/admin/Rails/First/config.ru:3:in `block in <main>'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /Users/admin/Rails/First/config.ru:in `new'
    from /Users/admin/Rails/First/config.ru:in `<main>'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:50:in `app'
    from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:130:in `log_to_stdout'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:67:in `start'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in `block in server'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Library/Ruby/Gems/2.0.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

很抱歉,如果不需要,但我真的不确定如何处理它。

2 个答案:

答案 0 :(得分:0)

查看以下教程。我意识到它适用于Windows,但它解决了我第一次安装时遇到的所有初始问题。

http://www.soheiokamoto.com/setting-up-ruby-on-rails-on-windows

帮助我完美安装的要点是;

在全新安装上运行gem update以确保所有内容都是最新的

答案 1 :(得分:0)

我不认为你在这个错误中是孤身一人。 确保你协调你的宝石版本,如果指定你的Rails&amp;版本的版本更好! Ruby gem可以避免版本控制中的潜在冲突。

发布你的Gemfile会很有帮助,但是如果没有看到它,我会说你的gem文件顶部指定你的Ruby版本,如:

source 'https://rubygems.org'
ruby '2.0.0'

然后指定您的Rails版本。虽然我只提供了以下方面没有问题:

gem 'rails'

您可以更加安全,并指定一个版本:

gem 'rails', '4.0.2'

然后为您的应用运行bundle install