0

注意:我花了一个上午仔细检查了关于这个主题的类似问题,但没有帮助。

我的问题

我正在关注 Michael Hartl 的 Ruby-on-Rails 教程。第一个演示应用程序运行良好。它显示“Welcome Aboard”,当我添加 /users 时,它会运行演示应用程序。我将它推送到 Heroku,它在那里运行,但只显示 Welcome Aboard 页面。添加 /users 得到“您要查找的页面不存在。”。我没有改变任何路线。看来我现在应该可以在 Heroku 上查看我的演示应用程序了。我很惊讶,因为教程非常详尽。

进一步的实验

我删除了public/index.html。并将其从 git 中删除并提交并使用git status. 当我尝试打开时,localhost/3000我得到了预期的“路由错误”。当我添加 /users 时,演示应用程序按预期工作。我没有更改 routes.rb。教程中没有指示我这样做。

现在我推送到 Heroku 并在那里打开我的应用程序,我现在得到“您要查找的页面不存在”。这似乎是对的。就好像我localhost/3000在本地运行时打开的一样。但是当我在 Heroku 添加 '/users' 时,我仍然会收到页面错误。我需要添加路线吗?教程中没有提到这一点(或者我忽略了一些东西)。

感谢这位 Rails 新手的帮助。

更多信息

我确实添加了一个指向users/index它的路由,现在我的 localhost 版本可以直接向应用程序打开,而无需手动添加users到 URL。但是当完全提交并推送到heroku时,我仍然会收到页面错误。

这是 rake 路由的输出:

~/Documents/demo_app: rake routes
users       GET    /users(.:format)          users#index
            POST   /users(.:format)          users#create
new_user    GET    /users/new(.:format)      users#new
edit_user   GET    /users/:id/edit(.:format) users#edit
user        GET    /users/:id(.:format)      users#show
            PUT    /users/:id(.:format)      users#update
            DELETE /users/:id(.:format)      users#destroy
root                                         users#index
4

1 回答 1

2

尝试这个

heroku run rake db:create
heroku run rake db:migrate

运行您的应用程序

# in your terminal write
heroku logs -e production

它将在您的终端中显示错误,以便您轻松理解。

于 2012-10-05T06:01:48.247 回答