在Ubuntu中运行rails s命令时出错

时间:2017-02-25 17:49:09

标签: ruby-on-rails ruby linux ubuntu spree

每当我运行rails s时,不会让服务器继续运行,而是立即退出。如果这是一个荒谬的问题我很抱歉,我对rails和ubuntu很新。我不确定您是否还需要其他信息。

=> Booting WEBrick
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Exiting
/var/lib/gems/2.3.0/gems/spree_core-3.2.0.rc3/app/models/spree/base.rb:1:in `<top (required)>': uninitialized constant ApplicationRecord (NameError)
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies/interlock.rb:11:in `loading'
    from /var/lib/gems/2.3.0/gems/spree_core-3.2.0.rc3/app/models/spree/payment_method.rb:2:in `<module:Spree>'
    from /var/lib/gems/2.3.0/gems/spree_core-3.2.0.rc3/app/models/spree/payment_method.rb:1:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies/interlock.rb:11:in `loading'
    from /var/lib/gems/2.3.0/gems/spree_core-3.2.0.rc3/app/models/spree/gateway.rb:2:in `<module:Spree>'
    from /var/lib/gems/2.3.0/gems/spree_core-3.2.0.rc3/app/models/spree/gateway.rb:1:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
    from /var/lib/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies/interlock.rb:11:in `loading'
    from /var/lib/gems/2.3.0/gems/spree_core-3.2.0.rc3/lib/spree/core/engine.rb:39:in `block in <class:Engine>'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `run'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
    from /usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
    from /usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
    from /usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
    from /usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
    from /usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/application.rb:352:in `initialize!'
    from /home/aaron/kmd/config/environment.rb:5:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /var/lib/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /home/aaron/kmd/config.ru:3:in `block in <main>'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
    from /home/aaron/kmd/config.ru:in `new'
    from /home/aaron/kmd/config.ru:in `<main>'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/server.rb:59:in `app'
    from /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/server.rb:124:in `log_to_stdout'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/server.rb:77:in `start'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /var/lib/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

1 个答案:

答案 0 :(得分:2)

Rails 5项目应该在其模型中具有 ApplicationRecord ,用作所有模型的基类。

您似乎正在使用 rails 5.0.1 狂欢是宝石,它可以扩展您当前的 rails app ;它的所有模型都来自 ApplicationRecord

rails应用程序中应该有一个名为 app / models / application_record.rb 的文件。如果没有,请使用以下内容创建它。

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end