Skip to content

Instantly share code, notes, and snippets.

@ncherro
Created March 4, 2012 18:32
Show Gist options
  • Save ncherro/1974301 to your computer and use it in GitHub Desktop.
Save ncherro/1974301 to your computer and use it in GitHub Desktop.
monkeypatch to Twitter Bootstrapify the Nested Form add / remove buttons
# put this in in config/initializers
require 'nested_form/builder_mixin'
module NestedForm
module BuilderMixin
alias_method :link_to_add_original, :link_to_add
alias_method :link_to_remove_original, :link_to_remove
def link_to_add(*args, &block)
options = args.extract_options!.symbolize_keys
options[:class] = [options[:class], 'btn'].compact.join(' ')
link_to_add_original *args, options, &block
end
def link_to_remove(*args, &block)
options = args.extract_options!.symbolize_keys
options[:class] = [options[:class], 'btn btn-danger'].compact.join(' ')
link_to_remove_original "<i class=\"icon-trash icon-white\"></i> #{args.first}".html_safe, options, &block
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment