2007-04-26
Layout in Rails - Part I
Rails里面的layout的主要思想是template的merge机制 — 即在布局中留下若干占位符(或者是pointcut, AOP中的术语)。当HTTP请求过来,响应页面将具体内容插入到对应的占位符合并而成完成的内容。这和以及在使用理念上是完全不一样的。站在具体响应页面的角度看,rails采用的是推(push)的技术,而后两者则是拉(pull)的技术。当然“推”的处理方法项目可维护性更好。下面我们主要说说在Rails的controller中对layout的控制范围。
1. method级别的控制。在某些特定的请求(对应rails controller里面一个method)需要特定的layout, 这时候可以
class ExampleController < AppplicationController
def index
render :layout => ‘my_layout’
end
def list
end
end
发表评论
- 浏览: 19525 次
- 性别:

- 来自: Mars

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
Share methods in Control ...
这个,我就尽量不用,或者找模型来代理,尽量让controller变得简单,至少m ...
-- by lgn21st -
Share methods in Control ...
原则上,helper产生的返回值都是<div>....</div>这 ...
-- by 7thbyte -
Share methods in Control ...
helper是为template准备的,在controller中调用helper ...
-- by zeroleonhart -
Share methods in Control ...
在RoR2.0的class ApplicationController里有一句 ...
-- by baryon -
RXML
xu_wccq 写道发现个好方法先把xml转人为Hash表(from_xml(p ...
-- by xu_wccq






评论排行榜