-3

I have a rails 4 app which I use with bootstrap and simple form.

I'm trying to follow this tutorial so that i can have a single click date picker instead of separate date, month and year fields.

https://learningnewtricks.wordpress.com/2013/07/03/bootstrap-date-picker-on-rails-so-simple/

I have implemented all of the steps in this tutorial, but nothing changes in the date picker.

I have:

gemfile:

gem 'bootstrap-datepicker-rails'

application.js

@import "bootstrap-sprockets";
@import "bootstrap";
//= require underscore
//= require gmaps/google
//= require jquery
//= require bootstrap
//= require bootstrap-sprockets
//= require bootstrap-slider
//= require jquery_ujs
//= require bootstrap-datepicker
//= require_tree .

application.css.scss

 *= require_framework_and_overrides.css.scss
 *= require bootstrap-datepicker
 *= require_self
 *= require_tree .

view (html.erb)

<%= f.date_select :start_date, :label => "When does this project begin?", 'data-behaviour' => 'datepicker', order: [:day, :month, :year] %>

How do you get a calendar selector for the date field?

Mel
  • 2,481
  • 26
  • 113
  • 273
  • Your application.js and application.css.scss files do not make any sense. How are you adding Bootstrap to your app: GEM or otherwise? – vanburen Nov 22 '15 at 08:02
  • gem 'sass-rails', '~> 5.0' gem 'bootstrap-sass', '~> 3.3.5' gem 'font-awesome-sass', '~> 4.4.0' gem 'bootstrap-slider-rails' gem 'bootstrap-datepicker-rails' – Mel Nov 22 '15 at 08:10
  • 1
    Please visit the bootstrap-sass [Docs](https://github.com/twbs/bootstrap-sass) so you can fix your application files. – vanburen Nov 22 '15 at 08:12
  • I have been over those docs a few times. Are you referring to: Then, remove all the *= require_self and *= require_tree . statements from the sass file. Instead, use @import to import Sass files. Do not use *= require in Sass or your other stylesheets will not be able to access the Bootstrap mixins or variables. Require Bootstrap Javascripts in app/assets/javascripts/application.js: //= require jquery //= require bootstrap-sprockets – Mel Nov 22 '15 at 08:18
  • ^^ is completely confusing for me. – Mel Nov 22 '15 at 08:18
  • When I try to follow these instructions all the formatting is completely lost. – Mel Nov 22 '15 at 08:19
  • You `application.css.css` needs to be named `application.css.scss`, this is where you'll need to import all your CSS files. You have @import in your `application.js`, these don't belong there: you just need to use either `//= require bootstrap` or `//= require bootstrap-sprockets` not both. – vanburen Nov 22 '15 at 08:22
  • it is named scss. sorry -the spellchecker keeps overriding me on this site – Mel Nov 22 '15 at 08:24
  • So i put '@import "bootstrap-sprockets"; @import "bootstrap"; in the css file? – Mel Nov 22 '15 at 08:28
  • I have changed as per your comment - but the date picker still isn't working – Mel Nov 22 '15 at 08:32
  • Have you tested to make sure bootstrap is now working correctly though? – vanburen Nov 22 '15 at 08:34
  • How do you test for that? – Mel Nov 22 '15 at 08:37
  • Inspect one of your pages to see if you css/js files are being loaded and you can always place some sample html on a page to see if it renders correctly. – vanburen Nov 22 '15 at 08:48
  • Oh - right - well yes. Except that my js tabs setup isn't working (although it didn't work properly before I made the changes you suggested) – Mel Nov 22 '15 at 08:54
  • @user2860931 : have you checked the `console` in your `browser debugger` ? . If yes , what `javascript` error it gives ? – huzefa biyawarwala Nov 22 '15 at 12:28

1 Answers1

0

The tutorial is for Rails 3 while you are using Rails 4. The homepage https://github.com/Nerian/bootstrap-datepicker-rails says that it integrates with Rails 3 asset pipeline (settings for later versions are mentioned later).

As you are trying to migrate your old project to the later Rails version, you probably disregard changes in the asset pipeline as mentioned here http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails

This possibly relates to your other questions as well.

benjamin
  • 2,185
  • 1
  • 14
  • 19