How can I create a helper that will take tags and put into links in Rails 3? -


i using acts_as_taggable_on, , everytime want display tags, use following:

  7     #tags   8       %label tags:   9       - @vendor.tags.each |tag|  10         = link_to tag.name, tag_path(tag.name)  

i have different models have tags, ideally single helper pass resource to...thinking something using content_tag , block....?

you can create helper display tags.

#tag_helper.rb def display_tags(tags)   tag_string = ""   tags.each |tag|     tag_string << link_to tag.name, tag_path(tag.name)   end   tag_string.html_safe end  #view.html.erb =display_tags(@vendor.tags) 

Comments