[英]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.