可以从Rails控制台访问生产数据库,但不能访问Rails App

时间:2014-03-10 05:52:34

标签: ruby-on-rails postgresql devise

当我尝试使用生产数据库中的rails控制台登录我的Devise应用程序时,我可以毫无困难地使用我的Rails应用程序时无法使用。

我使用rails c -e production从我的家庭环境启动我的Rails控制台(不是通过SSH或其他任何方式),然后继续执行app.post('/users/sign_in', {"user"=>{"email"=>"email", "password"=>"password"}}),后者成功:

Started POST "/users/sign_in" for 127.0.0.1 at 2014-03-10 05:37:31 +0000
Started POST "/users/sign_in" for 127.0.0.1 at 2014-03-10 05:37:31 +0000
Processing by DeviseSessionsController#create as HTML
Processing by DeviseSessionsController#create as HTML
  Parameters: {"user"=>{"email"=>"amar@sittr.co.nz", "password"=>"[FILTERED]"}}
  Parameters: {"user"=>{"email"=>"amar@sittr.co.nz", "password"=>"[FILTERED]"}}
Redirected to http://www.example.com/dashboard
Redirected to http://www.example.com/dashboard
Completed 302 Found in 1830ms (ActiveRecord: 1426.3ms)
Completed 302 Found in 1830ms (ActiveRecord: 1426.3ms)
 => 302

然后我可以使用app.get '/dashboard'密码保护页面,然后成功:

Started GET "/dashboard" for 127.0.0.1 at 2014-03-10 05:38:14 +0000
Started GET "/dashboard" for 127.0.0.1 at 2014-03-10 05:38:14 +0000
Processing by StaticPagesController#home as HTML
Processing by StaticPagesController#home as HTML
  Rendered static_pages/home.html.haml within layouts/application (139.6ms)
  Rendered static_pages/home.html.haml within layouts/application (139.6ms)
Completed 200 OK in 6370ms (Views: 686.2ms | ActiveRecord: 5087.6ms)
Completed 200 OK in 6370ms (Views: 686.2ms | ActiveRecord: 5087.6ms)
 => 200

这一切都按预期工作,除了当我尝试去生产网站并使用相同的凭据登录时,它给了我500错误Errno::ECONNREFUSEDdevise_sessions#create Connection refused - connect(2) for "localhost" port 9200。令我困惑的是,这表示它正试图连接到localhost,这是没有任何意义的。以下是我的database.yml文件(取出敏感位):

production:
  adapter: postgresql
  database: db_name
  pool: 5
  timeout: 5000
  host: rds.database.com
  port: 5432
  username: username
  password: password

如您所见,我已正确设置端口和主机。我究竟做错了什么?提前谢谢。

0 个答案:

没有答案