acts_as_taggable and Forms

acts_as_taggable Website

Problem: text_field('element', 'tag_names') returns a text field where the tag names are concatenated without spaces (since tag_names returns an array).

Here’s a helper method that returns a useful text field:

def tag_field(object_name, options = {})  
  object = instance_variable_get("@#{object_name}")  
  options.merge!(:value => object.tag_names.join(' '))
  return text_field(object_name, :tag_names, options)
end