Skip to content

Instantly share code, notes, and snippets.

@ches
Created January 16, 2011 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ches/781997 to your computer and use it in GitHub Desktop.
Save ches/781997 to your computer and use it in GitHub Desktop.
simple_form input builder for use with my mongoid_taggable fork
# Example simple_form input builder to render tags from an Array field,
# for use with my fork of mongoid_taggable:
#
# https://github.com/ches/mongoid_taggable
#
# Once you've configured your app to load this, use it in forms thusly:
#
# <%= f.input :tags, :as => :tags %>
#
module SimpleForm
module Inputs
class TagsInput < StringInput
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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment