以下是相关的控制器操作:
def create(conn, %{"post" => post_params}) do
changeset = Post.changeset(%Post{}, post_params)
case Repo.insert(changeset) do
{:ok, _post} ->
conn
|> redirect(to: page_path(conn, :thanks))
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
在开发中 - 此操作会在创建帖子后将用户重定向到感谢页面。在生产中;但是,它会将其重定向到example.com/posts
而不是example.com/thanks
。
在生产中,页面显示:
为什么会发生这种情况,我该如何解决?
提前致谢。
答案 0 :(得分:0)
问题是我没有通过运行heroku run mix ecto.migrate
在我的生产数据库中创建表。错误是因为帖子没有被创建。