Starting a new Rails 4 : III. a date picker bootstrap 3, rails 4, datepicker

Seeking a BS3 date picker …

There a library for bootstrap 2 ( but she’s not ready for bootstrap 3 … So I found a fork here : and use it until the standard library will update.


Just copy the CSS file and the JS file to you assets rails directory.


Two step : declare the class for the date picker, and place the javascript call. In view/users/_form.html.haml :

    = simple_form_for @user, :html => {:class => 'well form-horizontal'}  do |f|
      = f.error_notification
      = f.input :username
      = f.input :lastname
      = f.input :identity
      = f.input :email
      = f.input :birthdate, :as => :string, :input_html => {:class => 'datepicker col-span-3'}  
      = f.input :active
        = f.submit "Update", :class => "btn btn-primary" 
        = submit_tag 'Cancel', :type => :reset, :class => "btn btn-danger" 

          format: "yyyy-mm-dd",
          todayHighlight: true,
          todayBtn: 'linked',
          autoclose: true
      }); ;


Note that the date format must match the database date format. Check the documentation for the options.

comments powered by Disqus