Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Created February 21, 2014 08:48
Show Gist options
  • Select an option

  • Save stevenyap/9130849 to your computer and use it in GitHub Desktop.

Select an option

Save stevenyap/9130849 to your computer and use it in GitHub Desktop.
Bootstrap v3

Useful links:

Adding Bootstrap to Rails

  • Download Bootstrap
  • Copy bootstrap/dist/css/bootstrap.css and bootstrap/dist/css/bootstrap.min.css to vendor/assets/stylesheets
  • Copy bootstrap/dist/js/bootstrap.js and bootstrap/dist/js/bootstrap.min.js to vendor/assets/javascripts
  • Update app/assets/stylesheets/application.css *= require bootstrap
  • Update app/assets/javascripts/application.js //= require bootstrap

Default application.haml view

!!!
%html
  %head
    %title Openseas
    = stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true
    = javascript_include_tag "application", "data-turbolinks-track" => true
    %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}
    = csrf_meta_tags

    /[if lt IE 9]
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
  %body
    .container
      = yield

Simple_form wrappe

config.wrappers :form_horizontal,
  hint_class: :field_with_hint, error_class: :field_with_errors do |b|
  b.use :html5
  b.use :placeholder
  b.optional :maxlength
  b.optional :pattern
  b.optional :min_max
  b.optional :readonly
  b.use :label
  b.use :input, wrap_with: { tag: :div, class: 'col-md-6' }
  b.use :hint,  wrap_with: { tag: :span, class: :hint }
  b.use :error, wrap_with: { tag: :span, class: 'text-danger' }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment