编辑:对不起,标题有点不清楚,我想使用'半静态'页面,使用渲染助手和红宝石变量。 ERB模板系统等等。对不起,伙计们!我的错!在rails中处理嵌套静态页面的最佳方式是什么?
我一直在寻找创建嵌套的半静态页面为我正在建设一个rails 3.1.3应用程序,我还没有找到一个满足我所有需求的答案。有任何想法吗?
所有我遇到的解决方案都是关于创建只是顶级网页,就像这样:
- Site root
--- About (http://wwww.example.com/about)
--- Contact (http://wwww.example.com/contact)
--- Products (http://wwww.example.com/products)
--- Pricing (http://wwww.example.com/pricing
而我希望做类似
- Site root
--- About (http://wwww.example.com/about)
------ What we do (http://wwww.example.com/about/what-we-do)
------ Another sub-page (http://wwww.example.com/about/another-sub-page)
--- Contact (http://wwww.example.com/contact)
--- Products (http://wwww.example.com/products)
------ Product One (http://wwww.example.com/products/product-one)
------ Product Two (http://wwww.example.com/products/product-two)
--- Pricing (http://wwww.example.com/pricing)
我已经遇到了为每个页面映射静态控制器等解决方案,但这似乎并不是一个特别优雅的解决方案。
或创建一个通用的路线和控制器相匹配的要求,就像这样:
in routes.rb:
map.connect '*path', :controller => 'content', :action => 'show'
in content_controller.rb:
def show
render :action => params[:path].join('/')
end
,但似乎更不雅,有另一种方式我失踪?
我站在我的答案,也称这半静态是没有意义的。就像称一个女孩是一个半处女。 – pguardiario 2011-12-27 12:25:25
@pguardiario就我所知,半静态是非常有意义的。例如,一个页面包含硬编码的内容,但使用各种rails/ruby内部帮助程序构建,例如用于共享包含和内部资产管理的“render”。 – JoeP 2011-12-27 13:39:53
一个页面是或者不是静态的。这是一个二元状态。一个或一个零。没有涉及的模糊数学。在你描述的情况下,它不是静态的。 – pguardiario 2011-12-27 14:27:51