但似乎无法推动RAILS

但似乎无法推动RAILS

本文介绍了本地发球有效,但似乎无法推动RAILS_ENV = production heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序可以在本地环境(localhost:3000)上正常运行。它正在从我本地的postgres数据库中提取数据,但是我似乎没有更新生产环境。在我的页面上可以看到我的欢迎页面,但是当我单击导航时链接以查看另一个页面我遇到错误,我认为是因为该页面调用了数据库中找不到的数据。

I have my app working just fine on my local environment at localhost:3000. It is pulling data from my local postgres db, however I don't appear to be updating the production environment. My welcome page is viewable on my https://gcl.herokuapp.com page, but when I click the nav link to view another page I get an error, I'm assuming because that page calls on data from the db, which it cannot find.

我在做 $ rails db:migrate RAILS_ENV = production

我在终端中得到以下输出:

I get the following output in Terminal:

(0.2ms)  SELECT pg_try_advisory_lock(3666737882978712990);
ActiveRecord::SchemaMigration Load (0.6ms)  SELECT "schema_migrations".*
FROM "schema_migrations"
ActiveRecord::InternalMetadata Load (0.6ms)  SELECT
"ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2  [["key", :environment], ["LIMIT", 1]]
(0.2ms)  BEGIN
SQL (1.9ms)  UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3  [["value", "production"], ["updated_at", 2017-03-31 10:42:57 UTC], ["key", "environment"]]
(0.4ms)  COMMIT
(0.2ms)  SELECT pg_advisory_unlock(3666737882978712990)

我的Gemfile中有gem'pg'

I have gem 'pg' in my Gemfile

我的database.yml如下:

My database.yml looks like:

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

development:
 adapter: postgresql
 database: postgresql-rectangular-42683
 pool: 5
 timeout: 5000
test:
 adapter: postgresql
 database: postgresql-rectangular-42683
 pool: 5
 timeout: 5000

production:
 adapter: postgresql
 database: postgresql-rectangular-42683
 username: Simon
 password: *************

 pool: 5
 timeout: 5000`

有什么想法吗?大约一天以来一直在尝试各种事情:(

Any thoughts? Been trying various things for about a day now :(

Simon

推荐答案

哈哈,两分钟后,我发现了问题所在,并且像往常一样这很简单,我需要运行 $ heroku运行rake db:seed

Haha, two mins later I've found what the problem was, and as usual it was a simple one. I needed to run $ heroku run rake db:seed.

尽管这似乎只是添加了表,因为我的行仍然显示为10000中的0

Although this only seems to have added the tables, as my rows still show as 0 of 10000

,我的页面仍无法在加载,但无法加载100%确定与数据库有关。

Also, my pages still don't load at https://gcl.herokuapp.com/articles but not 100% sure that's related to the db.

这篇关于本地发球有效,但似乎无法推动RAILS_ENV = production heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:30