【发布时间】:2010-11-29 03:30:31
【问题描述】:
以下语句...
content_tag(:li, concept.title)
...返回类似:
<li>"My big idea"</li>
以下方法定义在调用时返回相同:
def list_of_concepts(part)
content_tag(:li, concept.title)
end
原来如此……
def list_of_concepts(part)
content_tag(:li, part.concepts.first.title)
end
但是下面...
def list_of_concepts(part)
for concept in part.concepts
content_tag(:li, concept.title)
end
end
...在我看来只是给了我一堆英镑符号(“#”),就像它返回真假或计数,而不是content_tag 返回的任何东西。如何让它返回 content_tag 返回的内容?
再次感谢,
史蒂文。
【问题讨论】:
标签: ruby loops return for-loop