public
Created — forked from ches/tags_input.rb

  • Download Gist
tags_input.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.