views:

111

answers:

1

Hi all,

The following statement...

content_tag(:li, concept.title)

...returns something like:

<li>"My big idea"</li>

The following method definition, when called, returns the same:

def list_of_concepts(part)
 content_tag(:li, concept.title)
end

As does...

def list_of_concepts(part)
 content_tag(:li, part.concepts.first.title)
end

But the following...

def list_of_concepts(part)
  for concept in part.concepts
    content_tag(:li, concept.title)
  end
end

...just gives me a bunch of pound signs ("#") in my view, like it's returning true or false or a count rather than whatever content_tag returns. How can I make it return what content_tag returns?

Thanks again,

Steven.

+7  A: 

the for loop doesn't return your data, try this:

def list_of_concepts(part)
  part.concepts.map { |c| content_tag(:li, c.title) }.join
end
amikazmi
Worked a charm. Cheers. :-)
steven_noble