【发布时间】:2019-05-14 04:13:37
【问题描述】:
我不知道从这里去哪里。
Rails 4.2.5、Ruby 2.3.8、Devise、Heroku 7.16.7
应用程序在本地运行良好,并成功部署到 Heroku。当我访问实时应用程序时,主页会按预期填充,并且可以访问关于页面。我有一个 wikis 索引链接,当我尝试访问它时,我收到下面的 wiki 错误。无需登录即可查看索引页面。
当我点击登录或注册链接时,我遇到了同样的错误。 Schema 显示了为两个模型创建的表。
我尝试过的事情:
在注释掉 devise_for: users 后从测试分支部署,推送到 Heroku 以便迁移运行,随后取消注释 devise_for: users 并将 agin 推送到 Heroku。运气不好。
我试过 rake db:reset。运气不好。
我在工厂文件中查找并没有找到对任一 Rails 模型的任何引用。
RAILS_ENV=test heroku rake db:migrate
维基错误
2018-12-13T00:08:10.414883+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "wikis" does not exist
2018-12-13T00:08:10.414885+00:00 app[web.1]: LINE 1: SELECT "wikis".* FROM "wikis" ORDER BY created_at DESC
2018-12-13T00:08:10.414887+00:00 app[web.1]: ^
2018-12-13T00:08:10.414888+00:00 app[web.1]: : SELECT "wikis".* FROM "wikis" ORDER BY created_at DESC):
2018-12-13T00:08:10.414890+00:00 app[web.1]: app/policies/wiki_policy.rb:42:in `resolve'
2018-12-13T00:08:10.414892+00:00 app[web.1]: app/controllers/wikis_controller.rb:26:in `index'
2018-12-13T00:08:10.414893+00:00 app[web.1]:
2018-12-13T00:08:10.414895+00:00 app[web.1]:
登录/注册错误
2018-12-13T00:09:49.468548+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist
2018-12-13T00:09:49.468550+00:00 app[web.1]: LINE 5: WHERE a.attrelid = '"users"'::regclass
2018-12-13T00:09:49.468552+00:00 app[web.1]: ^
2018-12-13T00:09:49.468553+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2018-12-13T00:09:49.468555+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2018-12-13T00:09:49.468557+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2018-12-13T00:09:49.468558+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2018-12-13T00:09:49.468560+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2018-12-13T00:09:49.468561+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2018-12-13T00:09:49.468564+00:00 app[web.1]: ORDER BY a.attnum
2018-12-13T00:09:49.468565+00:00 app[web.1]: ):
spec/factories/wikis.rb
FactoryGirl.define do
factory :wiki do
title "MyString"
body "MyText"
private false
user
end
end
spec/factories/users.rb
FactoryGirl.define do
factory :user do
email 'sample_user@google.com'
password 'sample_password'
end
end
非常感谢您对此的帮助。
提前谢谢你!
【问题讨论】:
-
你能确认迁移在 heroku 上成功运行了吗?
标签: ruby-on-rails ruby postgresql heroku devise