开发者

Rails - View Object Iteration Issue

开发者 https://www.devze.com 2023-02-06 12:11 出处:网络
When I iterate an object in my view, it renders the objects itself too. I have: @portfolio_queued = A开发者_StackOverflowrtist.where(:state => \'portfolio_queued\')

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消