开发者

Weird problem: collection object displaying in view?

When I run the following code in the view:

- if @object.winner.present? && @object.winner.prizes.any?
  %ul
    = 开发者_开发问答@object.winner.prizes.each do |p|
      %li= p.description.html_safe

It's returning this:

li prize1
li prize2
li prize3
...
[#<Prize object...> ... ]

Does anyone know why it is listing the @object.winner.prizes collection in the view directly after the last @object.winner.prizes object is displayed?

Extremely baffled! I'm using Rails v3.0.6


This is because you're using = when you should be using - to iterate over the objects:

- @object.winner.prizes.each do |p|
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜