我正在构建一个与此处概述的应用程序直接等效的应用程序http://guides.rubyonrails.org/getting_started.html。
当我尝试Post.create(:content => "A new post")
在 rails 控制台中进行操作时,一切都按预期/希望进行。
但是,当我将相同的代码放入应用程序时,然后使用工头启动应用程序时出现错误。这是完整的错误:
11:09:07 web.1 | started with pid 2578
11:09:08 web.1 | /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
11:09:08 web.1 | from /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
11:09:08 web.1 | from /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
11:09:08 web.1 | from /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:228:in `columns'
11:09:08 web.1 | from /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:243:in `column_defaults'
11:09:08 web.1 | from /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/base.rb:482:in `initialize'
11:09:08 web.1 | from /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/persistence.rb:44:in `new'
11:09:08 web.1 | from /home/ryan/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/persistence.rb:44:in `create'
11:09:08 web.1 | from app/models/newPost.rb:3:in `<main>'
11:09:08 web.1 | process terminated
11:09:08 system | sending SIGTERM to all processes
使用 Rails 3.2.3 和 ruby 1.9.2。
谢谢