Skip to content

Instantly share code, notes, and snippets.

@ches
Created August 26, 2011 08:09
Show Gist options
  • Save ches/1172956 to your computer and use it in GitHub Desktop.
Save ches/1172956 to your computer and use it in GitHub Desktop.
SimpleForm (1.4.x) input for mongoid_taggable -- place in app/inputs
# Input builder to render tags from an Array field, for use with my fork
# of mongoid_taggable:
#
# https://github.com/ches/mongoid_taggable
#
class TagsInput < SimpleForm::Inputs::StringInput
map_type :tags, :to => :text_field
protected
def html_options_for(namespace, extra)
formatted_tags = object.send(attribute_name).
try(:join, "#{object.send(:tags_separator)} ")
super.merge(:value => formatted_tags)
end
end
@ches
Copy link
Author

ches commented Oct 10, 2011

Sorry, this was written for SimpleForm 1.4.x. I haven't updated yet, so I'm not sure how the API has changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment