如何在 Rails 中将静态页面 (high_voltage) 设置为 root?
How can I set a static page (high_voltage) as root in Rails?
我使用 gem high_voltage 来获取静态页面并且它有效,但现在我想将其中之一定义为 root。
我没有手柄,Routes.rb应该怎么写?
您可以像这样配置到 High Voltage 页面的根路由:
# config/initializers/high_voltage.rb
HighVoltage.configure do |config|
config.home_page = 'home'
end
当访问站点的“/”路由时,它将呈现来自 app/views/pages/home.html.erb
的页面。
注意:High Voltage 还会创建搜索引擎友好的 301 重定向。任何访问路径“/home”的尝试都将被重定向到“/”。
来源:https://github.com/thoughtbot/high_voltage#specifying-a-root-path
我使用 gem high_voltage 来获取静态页面并且它有效,但现在我想将其中之一定义为 root。 我没有手柄,Routes.rb应该怎么写?
您可以像这样配置到 High Voltage 页面的根路由:
# config/initializers/high_voltage.rb
HighVoltage.configure do |config|
config.home_page = 'home'
end
当访问站点的“/”路由时,它将呈现来自 app/views/pages/home.html.erb
的页面。
注意:High Voltage 还会创建搜索引擎友好的 301 重定向。任何访问路径“/home”的尝试都将被重定向到“/”。
来源:https://github.com/thoughtbot/high_voltage#specifying-a-root-path