问题描述
重新表述我的问题以使其更清楚.
Rephrasing my question to make it clearer.
好的,我现在正在尝试在 heroku 上构建一个应用程序,但同时,我想将我的用户重定向到外部 url,例如:quickbrownfox.com
.
Ok, I'm trying to build an app on heroku right now, but meanwhile, I want to redirect my users to an external url, example: quickbrownfox.com
.
所以我要做的是修改根路由,这样任何试图访问我的应用程序的人都将被重定向到外部站点.
So what I'm trying to do is to modify the root route, so that whoever who tries to access my app will be redirected to the external site.
我通过向 routes.rb 添加条目来尝试此操作:
I attempted this by adding an entry to routes.rb:
root :to =>重定向('http://quickbrownfox.com')
这在本地工作正常,但是一旦我上传到 heroku(bamboo stack).似乎没有使用 routes.rb.它只是试图寻找我已删除的 index.html
.
This works fine locally, but once I upload to heroku (bamboo stack). It seems that routes.rb is not being used. It is just trying to look for index.html
which I had deleted.
参考 heroku 日志,我会得到一个:
Referring to the heroku logs, I'll get an:
2012-02-10T03:42:10+00:00 app[web.1]: 缓存:[GET/] 未命中
推荐答案
如果您想以 root 身份显示静态页面,您应该使用 High Voltage gem.这允许您按如下方式向您的网站添加静态页面:
If you want to display a static page as your root, you should be using the High Voltage gem. This allows you to add static pages to your site as follows:
- 将
gem 'high_voltage'
添加到您的Gemfile
- 将您的静态
home.html.erb
页面放在/app/views/pages/
- 使用
root to: => 路由到您的静态页面'high_voltage/pages#show', :id =>'家'
- Add
gem 'high_voltage'
to yourGemfile
- Put your static
home.html.erb
page in/app/views/pages/
- Route to your static page with
root to: => 'high_voltage/pages#show', :id => 'home'
不需要重定向.
可以在 https://github.com/thoughtbot/high_voltage 找到高压文档.
The High Voltage docs can be found at https://github.com/thoughtbot/high_voltage.
这篇关于route.rb 在本地工作,但不在 heroku 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!