gpt4 book ai didi

mysql - 尝试查看 Heroku 应用程序时出错

转载 作者:行者123 更新时间:2023-11-30 22:05:38 24 4
gpt4 key购买 nike

我刚开始使用 Rails 和 Heroku,一直在尝试推出一款在本地运行良好的应用程序。我可以将它推送到 heroku(貌似),但是当我尝试查看它时,我得到了

ActionView::Template::Error (PG::UndefinedTable: ERROR:  relation "users" does not exist

我从类似的 SO 帖子中挖掘出来,我认为它与应用程序在 heroku 中使用的数据库有关,但到目前为止使用 heroku run rake db:reset 然后 heroku运行 rake db:migrate 返回了完全相同的错误。我确定我在这里做了一些非常错误的事情,但我希望有人能帮我弄清楚。这是我使用 heroku logs 得到的结果:

2017-01-26T05:24:34.232181+00:00 app[web.1]: I, [2017-01-26T05:24:34.232138 #4]  INFO -- : [7baf7e95-1518-4773-9f3c-39aef34651f2] Completed 500 Internal Server Error in 7ms (ActiveRecord: 1.8ms)
2017-01-26T05:24:34.233452+00:00 app[web.1]: F, [2017-01-26T05:24:34.233406 #4] FATAL -- : [7baf7e95-1518-4773-9f3c-39aef34651f2]
2017-01-26T05:24:34.233498+00:00 app[web.1]: F, [2017-01-26T05:24:34.233455 #4] FATAL -- : [7baf7e95-1518-4773-9f3c-39aef34651f2] ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "users" does not exist
2017-01-26T05:24:34.233500+00:00 app[web.1]: LINE 1: SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LI...
2017-01-26T05:24:34.233501+00:00 app[web.1]: ^
2017-01-26T05:24:34.233501+00:00 app[web.1]: : SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT $1):
2017-01-26T05:24:34.233649+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] 21: <div class="container">
2017-01-26T05:24:34.233648+00:00 app[web.1]: F, [2017-01-26T05:24:34.233606 #4] FATAL -- : [7baf7e95-1518-4773-9f3c-39aef34651f2] 20: <div class="header">
2017-01-26T05:24:34.233650+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] 22: <a href="../messages"><h1 class="logo">MessagesApp</h1> <img class="logo-img" src="http://vignette2.wikia.nocookie.net/titanfall/images/3/3a/Icon_Chat.png/revision/latest?cb=20140504182858"></a>
2017-01-26T05:24:34.233650+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] 23: <% if logged_in? %>
2017-01-26T05:24:34.233651+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] 24: <%= link_to "Log out".html_safe, logout_path, method: "delete", class: "login-btn btn btn-default navbar-btn" %>
2017-01-26T05:24:34.233652+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] 25: <% else %>
2017-01-26T05:24:34.233652+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] 26: <%= link_to "Log in".html_safe, login_path, class: "login-btn btn btn-default navbar-btn" %>
2017-01-26T05:24:34.233692+00:00 app[web.1]: F, [2017-01-26T05:24:34.233648 #4] FATAL -- : [7baf7e95-1518-4773-9f3c-39aef34651f2]
2017-01-26T05:24:34.233718+00:00 app[web.1]: F, [2017-01-26T05:24:34.233685 #4] FATAL -- : [7baf7e95-1518-4773-9f3c-39aef34651f2] app/helpers/sessions_helper.rb:7:in `current_user'
2017-01-26T05:24:34.233718+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] app/helpers/sessions_helper.rb:11:in `logged_in?'
2017-01-26T05:24:34.233719+00:00 app[web.1]: [7baf7e95-1518-4773-9f3c-39aef34651f2] app/views/layouts/application.html.erb:23:in `_app_views_layouts_application_html_erb__1527317900822670125_70088753231660'
2017-01-26T05:24:34.240424+00:00 heroku[router]: at=info method=GET path="/" host=nameless-bayou-71899.herokuapp.com request_id=7baf7e95-1518-4773-9f3c-39aef34651f2 fwd="207.67.119.130" dyno=web.1 connect=1ms service=12ms status=500 bytes=1733

这是我认为相关的代码:

<% @messages.each do |message| %>
<div class="message <%= 'right' if logged_in? && message.user_id==current_user.id %>">

<% if message.user_id==current_user.id %>
<%= '<p class="user_name text-right">Me</p>'.html_safe %>
<% else %>
<p class="user_name"><%= message.user.name %></p>
<% end %>

<p class="content"><%= message.content %></p>
<p class="time <%= 'right' if message.user_id==current_user.id %>"><%= time_ago_in_words(message.created_at) %><br>
<% if message.user_id==current_user.id %>
<%= link_to 'Delete', message_path(message),
class: "delete-link",
method: :delete,
data: { confirm: 'Are you sure?' } %></p>
<% end %>
</div>
<% end %>

最佳答案

您可以尝试将消息模型的迁移分为两个单独的迁移。第一次迁移创建模型。第二次迁移添加引用关系

关于mysql - 尝试查看 Heroku 应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41867442/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com