Skip to content

Instantly share code, notes, and snippets.

View jlberglund's full-sized avatar

Jonathan Berglund jlberglund

View GitHub Profile
@jlberglund
jlberglund / token_input.rb
Created November 15, 2011 03:42
SimpleForm Custom Input for jQuery Tokeninput
# SimpleForm (https://github.com/plataformatec/simple_form)
# jQuery Tokenninput (http://loopj.com/jquery-tokeninput/)
class TokenInput < SimpleForm::Inputs::Base
def input
input_html_options[:"data-url"] = "/#{reflection.klass.name.tableize}.json"
if @builder.object.send(reflection.name).nil?
if input_html_options[:value]
object = reflection.klass.find(input_html_options[:value])
end
else