简体   繁体   English

无法在heroku上部署应用程序,总是得到“您要查找的页面不存在。”错误

[英]Can't deploy app on heroku, always get “The page you were looking for doesn't exist.” error

Hi I'm trying to deploy an app made with help of "Agile web development by S.Ruby" and I always get the same error - The page you were looking for doesn't exist. 嗨,我正在尝试部署借助“ S.Ruby进行的敏捷Web开发”制作的应用程序,但我总是遇到相同的错误-您正在寻找的页面不存在。

You may have mistyped the address or the page may have moved. 您可能输入了错误的地址,或者页面已经移动。

I've already tried to migrate my DB on Heroku - that wasn't the case.I think something is wrong with routes.rb file, but I can't understand what is incorrect exactly,please help me to solve this problem 我已经尝试在Heroku上迁移数据库-并非如此。我认为route.rb文件出了点​​问题,但是我不明白到底是什么错误,请帮助我解决此问题

Here is my routes.rb file: 这是我的routes.rb文件:

Depot::Application.routes.draw do
  get 'admin' => 'admin#index'

  controller :sessions do
    get  'login' => :new
    post 'login' => :create
    delete 'logout' => :destroy
  end

  get "sessions/create"
  get "sessions/destroy"

  resources :users

  resources :products do
    get :who_bought, on: :member
  end

  scope '(:locale)' do
    resources :orders
    resources :line_items
    resources :carts
    root 'store#index', as: 'store', via: :all
  end
end

As Michal correctly points out you miss the root path. 正如Michal正确指出的那样,您错过了根路径。 You have defined a route inside the scope you use to get to the different locales, but not a global root. 您已在用于访问不同语言环境的范围内定义了一条路由,但未定义全局根。 This is not a Heroku problem, it won't work on your local server either. 这不是Heroku问题,也无法在您的本地服务器上运行。

So, http://your_server.com/en will work, but http://your_server.com will not. 因此, http://your_server.com/en可以工作,但http://your_server.com不能工作。

You need to add a root path outside all scopes, like so: 您需要在所有范围之外添加一个根路径,如下所示:

root 'store#index'

You will have to set a default locale or something like that. 您将必须设置默认语言环境或类似的内容。 You can leave the other root directive inside the scope, as you have named it explicitly (with as: 'store' ) there won't be any conflict. 您可以将另一个root指令保留在范围内,因为您已将其明确命名(使用as: 'store' ),所以不会有任何冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在商店上安装后的Heroku Shopify应用程序“您要查找的页面不存在。” - Heroku Shopify App after installation on shop “The page you were looking for doesn't exist.” rails heroku错误:未定义路线,但路线存在(您要查找的页面不存在。) - rails heroku error: no route defined, but route is there (The page you were looking for doesn't exist.) “您要查找的页面不存在。”编辑表单 - “The page you were looking for doesn't exist.” edit form Heroku Rails设置“您正在寻找的页面不存在。” - Heroku Rails Setup “The page you were looking for doesn't exist.” heroku“您要查找的页面不存在。”遵循Hartl的RoR指南 - heroku “The page you were looking for doesn't exist.” following Hartl's RoR guide Cloud9,GitHub和Heroku(您要查找的页面不存在。) - Cloud9, GitHub and Heroku (The page you were looking for doesn't exist.) 为什么当我在Heroku的另一个窗口中打开新链接时显示“您要查找的页面不存在”的原因。 - Why is it when I open a new link in another window on Heroku it says “The page you were looking for doesn't exist.” Heroku:您要查找的页面不存在 - Heroku: The page you were looking for doesn't exist 您所寻找的页面不存在 - Heroku The page you were looking for doesn't exist Rails / Heroku您正在寻找的页面不存在 - Rails/Heroku The page you were looking for doesn't exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM