使用“render”时指定命名空间与 Rails 3 中的对象
因此,您可以在rails中执行类似的操作:
@features.each do |feature|
render feature
end
它会根据类名在views/features
文件夹中查找名为_feature.html.erb
的部分。
但是如果功能位于 cms 命名空间中怎么办? 可以指定命名空间吗?做这样的事情(显然它不起作用)
render [:cms, feature]
Thx
So, you can do something like that in rails:
@features.each do |feature|
render feature
end
and it will look for a partial called _feature.html.erb
in the views/features
folder, based on the class name.
But what if features are in a cms namespace?
Is it possible to specify the namespace? Doing something like this (it doesnt work, obviously)
render [:cms, feature]
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须更明确:
这将渲染“app/views/cms/_feature.html.erb”部分,其中对象为“feature”。
You'll have to be more explicit:
This will render the 'app/views/cms/_feature.html.erb' partial with the object being 'feature'.