Rails - View Object Iteration Issue
When I iterate an object in my view, it renders the objects itself too.
I have:
@portfolio_queued = A开发者_StackOverflowrtist.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?
Ok, so just repalcing
= for artist in @portfolio_queued
for
- for artist in @portfolio_queued
does the trick.
Maybe this is just personal preference but I find that hard to read and would write it as
= @portfolio_queued.each do |artist|
%p
artist.name
%br
artist.status
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.
精彩评论