Skip to content

Instantly share code, notes, and snippets.

@franciscoj
Created November 2, 2011 16:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franciscoj/1334203 to your computer and use it in GitHub Desktop.
Save franciscoj/1334203 to your computer and use it in GitHub Desktop.
Use twitter bootstrap with simple_form
# config/initializer/simple_form.rb
SimpleForm.setup do |config|
config.hint_class = "hint input"
config.error_class = 'error input'
config.wrapper_class = :clearfix
config.wrapper_error_class = :error
end
# config/initializer/simple_form_bootstrap.rb
SimpleForm::Inputs.constants.each do |klazz|
next if klazz == :Base
"SimpleForm::Inputs::#{klazz.to_s}".constantize.class_eval do
def input_with_surrounding_div
@builder.template.content_tag :div, input_without_surrounding_div, :class => "input"
end
alias_method_chain :input, :surrounding_div
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment