此时我已多次执行命令heroku run rake db:migrate
,这不是我遇到的问题。
我的应用程序在localhost上完美运行,但是当我部署到Heroku时,我的/ guestbooks页面收到来自Heroku日志的500错误。
我运行了rake db:reset然后删除了我的测试数据库记录,认为我的数据库可能需要从测试到生产干净,但这不起作用。我然后运行heroku运行rake db:再次迁移无济于事。该应用程序仍适用于localhost
以下是我的MVC和路线。我想知道是否有人发现可能导致问题的任何事情。我被卡住了......
控制器
class GuestbooksController < ApplicationController
before_action :load_page
def index
@guestbook = Guestbook.new
end
def create
@guestbook = Guestbook.new(guestbook_params)
if @guestbook.save
flash.now[:notice] = "Thanks for taking the time to write us! We greatly appreciate it!"
render :new
else
flash.now[:notice] = "Your message failed to post, please try again"
render :new
end
end
private
def load_page
@guestbooks = Guestbook.page(params[:page])
end
def guestbook_params
params.require(:guestbook).permit(:name, :email, :message)
end
end
模型
class Guestbook < ActiveRecord::Base
paginates_per 5
end
查看
<div class="paginate">
<%=paginate @guestbooks%>
</div>
<div class="span1">
<% @guestbooks.each do |g| %>
<br/>
<h4><%= g.name %>, <%= g.created_at %><br/></h4>
<%= g.message %><br/>
<p>-----------------------------------------------------------------------------------------------------------------------</p>
<% end %>
</div>
<%= simple_form_for @guestbook, url: guestbooks_path, method: :post do |f| %>
<div class="span2"><%= f.input :name %></div>
<div class="span2"><%= f.input :email %></div>
<div class="span3"><%= f.input :message %></div>
<div class="span4"><%= f.button :submit %></div><br/><br/><br/>
<% end %>
resources :guestbooks, only: [:create, :index]
日志
Dec 07 11:51:16 allbugsaside heroku/router: at=info method=GET path="/guestbooks" host=allbugsaside.herokuapp.com request_id=c09830f2-e460-4700-9907-43a97391001f fwd="96.248.110.224" dyno=web.1 connect=1ms service=18ms status=500 bytes=1754
Dec 07 11:51:17 allbugsaside heroku/router: at=info method=GET path="/favicon.ico" host=allbugsaside.herokuapp.com request_id=8c9a1f54-ea28-4d82-bc33-9e8dd3b1d56f fwd="96.248.110.224" dyno=web.1 connect=2ms service=5ms status=304 bytes=133