ruby-on-rails - Rails 应用程序无法在 Heroku 上加载根路径“/”
问题描述
在将我的 Rails 应用程序部署到 Heroku 后,我收到以下消息“您正在寻找的页面不存在”。它在我的本地主机上运行得很好,只是在 Heroku 上出现了问题。
我确保heroku run rake db:migrate
在 routes.rb 中运行并将我的根设置为root 'welcome#index'
当我在rake routes
本地运行时,我得到以下(不是完整列表)
Prefix Verb URI Pattern Controller#Action
root GET / welcome#index
welcome_index GET /welcome(.:format) welcome#index
运行时根路径明显丢失heroku run rake routes
Prefix Verb URI Pattern Controller#Action
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
Heroku 日志显示以下内容:
2020-06-25T01:46:58.550276+00:00 app[web.1]: F, [2020-06-25T01:46:58.550205 #4] FATAL -- : [b01338d3-12f9-486c-8b05-0f7e525d01ba] ActionController::RoutingError (No route matches [GET] "/"):
我还删除了我的 Heroku 应用程序并从头开始。我似乎无法弄清楚为什么我的根路径没有被识别。
添加Routes.rb文件内容
Rails.application.routes.draw do
root 'welcome#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
解决方案
推荐阅读
- javascript - Ramda Pipe 抛出 TypeError: Cannot read property of 'length' undefined
- ios - PHImageManager 抛出“机会性图像请求的第一阶段返回了非表格格式的图像,这不是致命的,但它是意外的”
- java - 将其他两个之间的单词排除为正则表达式
- java - 映射到 Java 8 中的运行总和
- angular - Angular 7:注入的服务未定义
- php - 每个 PHP 混合数组
- angular - Angular 7 - [弃用] 主线程上的同步 XMLHttpRequest 已弃用,因为它对最终用户的体验产生不利影响
- liferay - 在 liferay 访客页面重定向上获取 404
- python - IOError: [Errno -9998] 在 Spyder (Python 2.7) 上使用 PyAudio 时通道数无效
- python - 将 Python 类对象编译成列表