RoR可以通过控制台连接到postgresql数据库,但不能通过app中的代码连接

时间:2012-05-06 15:11:57

标签: ruby-on-rails ruby activerecord

我正在构建一个直接等同于此处列出的应用的应用http://guides.rubyonrails.org/getting_started.html

当我尝试在rails控制台中执行Post.create(:content => "A new post")时,一切都按预期/希望工作。

然而,当我在应用程序中放入相同的代码时,然后与领班启动应用程序我收到错误。这是完整的错误:

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。

由于

0 个答案:

没有答案