“render @collection”是什么意思?做?
我试图通过查看示例应用程序来更好地学习 Rails,同时查看 railscasts.com 源代码的这一行,我注意到它是这样做的:
<div class="episodes">
<%= render @episodes %>
</div>
这里到底发生了什么?为什么渲染函数中没有记录这一点?或者是吗?
I'm trying to learn Rails better by looking at example applications, and while looking at this line of the source of railscasts.com, I noticed it does this:
<div class="episodes">
<%= render @episodes %>
</div>
What exactly is going on here? Why isn't this documented on the render function? Or is it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个方便的快捷方式,
这是另一种方式
,它的作用非常明显:)
希望这是有道理的:)
顺便说一句,我也找不到这方面的文档,这真的很令人惊讶。
This is a handy shortcut for doing
which is another way of doing
which is pretty obvious in what it does :)
Hope that makes sense :)
btw it's really surprising I couldn't find the docs for this too.
的简写
这是render :partial => “剧集”,:集合=> @episodes
上面的表单记录在 Rails API 文档 中的
render (ActionController ::基础)
。据我所知,除了 Rails 指南 之外,速记形式没有记录。This is shorthand for
render :partial => "episode", :collection => @episodes
The form above is documented in the Rails API docs under
render (ActionController::Base)
. The shorthand form is not documented as far as I can see except in the Rails Guides.这是一个新的快捷方式:
您还可以对单个项目执行快捷方式
This is a new shortcut:
You can also do shortcuts with single items