Skip to content

Instantly share code, notes, and snippets.

@ncherro
Created April 30, 2012 03:21
Show Gist options
  • Save ncherro/2555189 to your computer and use it in GitHub Desktop.
Save ncherro/2555189 to your computer and use it in GitHub Desktop.
Nested Form monkeypatch - add / remove buttons with twitter bootstrap classes
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 btn-inverse'].compact.join(' ') unless options[:plain]
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(' ') unless options[:plain]
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