Rails 5和Heroku - Postgres不工作

时间:2017-03-16 00:30:14

标签: ruby-on-rails ruby postgresql heroku ruby-on-rails-5

我一直在关注我能找到的每个教程,但仍然无法在Heroku上正确部署我的Rails 5应用程序。我可以启动并运行该站点,但似乎没有数据库连接(我切换到Postgres),所以我无法登录或任何东西。我也无法访问网站上的某些页面 - 我没有收到错误,只是一个空白页面。任何帮助都会非常棒!
谢谢!!
以下是代码:

Postgres问题:

的database.yml

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000
  host: ""

development:
  adapter: postgresql
  encoding: unicode
  database: demo_test_development
  pool: 5
  username: Brandon
  password: "password"
  timeout: 5000

test:
  adapter: postgresql
  encoding: unicode
  database: demo_test_test
  pool: 5
  username: Brandon
  password: "password"
  timeout: 5000

Heroku Logs

app[web.1]: I, [2017-03-16T00:08:56.626013 #4]  INFO -- : [ce14b2b6-523e-446b-b80e-e6cab9de1234] Completed 500 Internal Server Error in 134ms (ActiveRecord: 30.9ms)
app[web.1]: F, [2017-03-16T00:08:56.627256 #4] FATAL -- : [ce14b2b6-523e-446b-b80e-e6cab9de1234]   
app[web.1]: F, [2017-03-16T00:08:56.627343 #4] FATAL -- : [ce14b2b6-523e-446b-b80e-e6cab9de1234] ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "users" does not exist
app[web.1]: LINE 8:                WHERE a.attrelid = '"users"'::regclass
app[web.1]:                                           ^
app[web.1]: :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
app[web.1]:              (SELECT c.collname FROM pg_collation c, pg_type t
app[web.1]:                WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation),
app[web.1]:                      col_description(a.attrelid, a.attnum) AS comment
2017-03-16T00:08:56.632358+00:00 heroku[router]: at=info method=POST path="/login_user" yno=web.1 connect=72ms service=243ms status=500 bytes=1669 protocol=https
app[web.1]:                 FROM pg_attribute a LEFT JOIN pg_attrdef d
app[web.1]:                   ON a.attrelid = d.adrelid AND a.attnum = d.adnum
app[web.1]:                WHERE a.attrelid = '"users"'::regclass
app[web.1]:                  AND a.attnum > 0 AND NOT a.attisdropped
app[web.1]:                ORDER BY a.attnum
app[web.1]: ):
app[web.1]: F, [2017-03-16T00:08:56.627413 #4] FATAL -- : [ce14b2b6-523e-446b-b80e-e6cab9de1234]   
app[web.1]: F, [2017-03-16T00:08:56.627489 #4] FATAL -- : [ce14b2b6-523e-446b-b80e-e6cab9de1234] app/models/user.rb:33:in 

网址无效

Heroku Logs

heroku[router]: at=info method=GET path="/accomodations" host={deleted on purpose} request_id=cb06d7d3-9236-4eb0-b5a7-c05c7db538d8 fwd="73.169.192.70" dyno=web.1 connect=1ms service=22ms status=406 bytes=182 protocol=https
app[web.1]: I, [2017-03-16T00:24:16.409234 #4]  INFO -- : [cb06d7d3-9236-4eb0-b5a7-c05c7db538d8] Started GET "/accomodations" for 73.169.192.70 at 2017-03-16 00:24:16 +0000
app[web.1]: I, [2017-03-16T00:24:16.415902 #4]  INFO -- : [cb06d7d3-9236-4eb0-b5a7-c05c7db538d8] Processing by HomesController#accomodations as HTML
app[web.1]: I, [2017-03-16T00:24:16.425975 #4]  INFO -- : [cb06d7d3-9236-4eb0-b5a7-c05c7db538d8] Completed 406 Not Acceptable in 8ms (ActiveRecord: 0.0ms)
app[web.1]: F, [2017-03-16T00:24:16.427668 #4] FATAL -- : [cb06d7d3-9236-4eb0-b5a7-c05c7db538d8]   
2017-03-16T00:24:16.427810+00:00 app[web.1]: F, [2017-03-16T00:24:16.427746 #4] FATAL -- : [cb06d7d3-9236-4eb0-b5a7-c05c7db538d8] ActionController::UnknownFormat (HomesController#accomodations is missing a template for this request format and variant.
app[web.1]: 
app[web.1]: request.formats: ["text/html"]
app[web.1]: request.variant: []):
app[web.1]: F, [2017-03-16T00:24:16.427823 #4] FATAL -- : [cb06d7d3-9236-4eb0-b5a7-c05c7db538d8]   
app[web.1]: F, [2017-03-16T00:24:16.427921 #4] FATAL -- : [cb06d7d3-9236-4eb0-b5a7-c05c7db538d8] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.2/lib/action_controller/metal/implicit_render.rb:43:in `default_render'

1 个答案:

答案 0 :(得分:0)

  1. 您的应用是否在本地计算机上正常运行?

  2. 您是否通过以下命令在heroku上运行迁移文件:

    heroku run rake db:migrate