Frage

I have this code that outputs a list of users' interests and I can't figure out how to titleize each tag of the list.

<%= raw follower.pursuit_list.map { |p| link_to p, "#" }.join(', ') %>
War es hilfreich?

Lösung

This code should do it:

follower.pursuit_list.map { |p| link_to p.name.titleize, "#" }.join(', ').html_safe

It implies that the PursuitList object responds to the name method, which I consider as the Tag's name in this code.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top