Rails - 查看对象迭代问题
当我在视图中迭代一个对象时,它也会渲染对象本身。
我有:
@portfolio_queued = Artist.where(:state => 'portfolio_queued')
并且:
= for artist in @portfolio_queued
%p
= "#{artist.name}"
%br
= "#{artist.state}"
它正在渲染:
mauko
portfolio_queued
quiroga
portfolio_queued
quiroga
portfolio_queued
#<Artist:0x10652ca90>#<Artist:0x1065296b0>#<Artist:0x106529340>
有帮助吗?
When I iterate an object in my view, it renders the objects itself too.
I have:
@portfolio_queued = Artist.where(:state => 'portfolio_queued')
And:
= for artist in @portfolio_queued
%p
= "#{artist.name}"
%br
= "#{artist.state}"
And it's rendering:
mauko
portfolio_queued
quiroga
portfolio_queued
quiroga
portfolio_queued
#<Artist:0x10652ca90>#<Artist:0x1065296b0>#<Artist:0x106529340>
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,只需替换
for
就可以了。
Ok, so just repalcing
for
does the trick.
也许这只是个人喜好,但我发现很难阅读,并将其写为
另外,再次个人喜好 - 对不是文本块的内容使用段落标签被认为是糟糕的 SEO/CSS; span、div 或表格单元格可能会更好。
Maybe this is just personal preference but I find that hard to read and would write it as
Also, again personal preference - using paragraph tags for something that isn't a block of text is perceived as poor SEO/CSS; a span, div or table cell might be better.