我正在尝试使用high_voltage gem在我的Rails应用中提供静态页面。我想要的是个别部分获得他们自己的文件夹,但不能完全让它工作&无法在网络上找到解决方案。
我想要的是什么:
RAILS_ROOT / app / views / pages /(页面)路由为'/(page)'
而RAILS_ROOT / app / views / pages /(目录)/(页面)=> '/(目录)/(页)'
这是我的尝试:
routes.rb中:
Cam4::Application.routes.draw do
root :to => 'high_voltage/pages#show', :id => 'index'
match '/:id' => 'high_voltage/pages#show', :as => :static, :via => :get
scope "ruby" do
match '/ruby/:id' => 'high_voltage/pages/ruby#show', :as => :static, :via => :get
end
end
非常感谢,
卡梅伦
答案 0 :(得分:2)
实际上最终使用路由通配来解决问题。 给定Rails 3.2.5应用程序运行high_voltage,视图路径:
RAILS_ROOT / app / views / pages / id [=> '/ pages / id'或只是'/ id']
RAILS_ROOT / app / views / pages / ruby / id [=> 'pages / ruby / id'或'ruby / id']
routes.rb中:
Cam4::Application.routes.draw do
root :to => 'high_voltage/pages#show', :id => 'index'
match '/*id' => 'high_voltage/pages#show', :as => :static, :via => :get
end