20

I am trying to get bootstrap javascript working in my rails 4 app.

I asked these questions but haven't been able to get any help.

https://stackoverflow.com/questions/33685338/rails-with-bootstrap-tabs
https://stackoverflow.com/questions/33852687/rails-4-bootstrap-date-picker

I am increasingly feeling defeated by this challenge. It's depressing that bootstrap is described as a simple tool for rails. I would be happy to pay USD100 if someone could help be solve this problem.

My problem is specifically with the javascript functions. My tabs don't work. When you click the link, nothing happens. Also, the date picker doesn't work (I was expecting a calendar to pick a date in a single click).

In my gem file I have:

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'
gem 'jquery-rails'

In my application.html.erb, I have:

<link href='http://fonts.googleapis.com/css?family=Quicksand|Roboto:300' rel='stylesheet' type='text/css'>
        <link href='http://fonts.googleapis.com/css?family=Noto+Sans' rel='stylesheet' type='text/css'>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="p:domain_verify" content="44c82789b3dcecac427e4b65123fb68d"/>
        <title><%= content_for?(:title) ? yield(:title) : "RE" %></title>
    <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Ae" %>">
          <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => false %>
          <%= javascript_include_tag "application", "data-turbolinks-track" => false %>
          <%= csrf_meta_tags %>
          <%= favicon_link_tag %>
          <script src="https://www.google.com/jsapi"></script>
          <script src="https://www.youtube.com/iframe_api"></script>

Turbolinks is off because i use olark.

In my stylesheets folder, I have files called:

application.css.scss:

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

Following comments set out below, I changed this file to be named application.scss and changed the order and referencing to:

*= require_tree .
 *= require_self
 *= require framework_and_overrides.css.scss
 *= require bootstrap-datepicker
 */

framework_and_overrides.css.scss

@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome-sprockets";
@import "font-awesome";
@import "bootstrap-slider";

In my javascript folder, I have a file called:

application.js:

 //= require jquery
//= require jquery_ujs
//= require underscore
//= require gmaps/google
//= require bootstrap-slider
//= require bootstrap-sprockets
//= require bootstrap-datepicker
//= require_tree .

project_dates.coffee.js

 $(document).on "focus", "[data-behaviour~='datepicker']", (e) ->
 - $(this).datepicker
 - format: "dd-mm-yyyy"
 - weekStart: 1
 - autoclose: true

Then, In my view I am trying to use bootstrap tabs, so that clicking on a tab renders a partial beneath the links bar:

<div class="containerfluid">

        <div class="row" style="margin-top:50px">
            <div class="col-xs-10 col-xs-offset-1">
                <ul class="nav nav-tabs nav-justified">
                    <li role="presentation" class="active"> <a href="#terms" aria-controls="terms" role="tab" data-toggle="tab">Terms</a></li>
                    <li role="presentation"> <a href="#privacy" aria-controls="privacy" role="tab" data-toggle="tab">Privacy</a></li>
                    <li role="presentation"> <a href="#licence" aria-controls="licence" role="tab" data-toggle="tab">Licence</a></li>
                    <li role="presentation"> <a href="#trust" aria-controls="trust" role="tab" data-toggle="tab">Trust</a></li>
                    <li role="presentation"> <a href="#reliance" aria-controls="reliance" role="tab" data-toggle="tab">Reliance</a></li>
                    <li role="presentation"> <a href="#pricing" aria-controls="pricing" role="tab" data-toggle="tab">Pricing</a></li>

                </ul>   
            </div>

        </div>


    <div class="row">
        <div class="col-xs-10 col-xs-offset-1">
            <div class="intpolmin" style="margin-top: 50px; margin-bottom: 30px"> 
             We give meaning to other words used in these terms and policies throughout, and identify those words as having an ascribed meaning, with <em>emphasised</em> text.
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-8 col-xs-offset-2">
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="terms"><%= render 'pages/legalpolicies/terms' %></div>
                <div role="tabpanel" class="tab-pane" id="privacy"><%= render 'pages/legalpolicies/privacy' %></div>

                <div role="tabpanel" class="tab-pane" id="licence"><%= render 'pages/legalpolicies/licence' %></div>
                <div role="tabpanel" class="tab-pane" id="trust"><%= render 'pages/legalpolicies/trust' %></div>

                <div role="tabpanel" class="tab-pane" id="reliance"><%= render 'pages/legalpolicies/reliance' %></div>
                <div role="tabpanel" class="tab-pane" id="pricing"><%= render 'pages/legalpolicies/pricing' %></div>

            </div>
        </div>
    </div>
</div>  

Nothing at all happens when you click on the links.

In my project dates form, I have this form field:

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

It does not make a date picker. Instead it's just three separate fields for d/m/y. Also, the label doesn't display -but I can work around that problem.

Is there something wrong with my setup?

When I change my application.js to remove:

//= require bootstrap

Then the js works so that when you click one of the tab links across the top, it jumps down a long page of text to the point where the relevant text starts. That's not what I want. I want to click on the tab link and for that to cause the relevant partial to render beneath the links (and all of the other partials not to render).

There are no changes to the date picker problem that result from this change to the application.js

When I try adding:

Bundler.require(:default, Rails.env)

to my config/application.rb (as per this post Bootstrap-sass gem Javascript not Working in Rails 4)

I get no different result to the problems outlined above

When I try adding

//= require bootstrap-sprockets

to my application.js (after jquery), the js stops working - so that when i click the link in the tabs menu, nothing at all happens

I am aware the user guide for https://github.com/twbs/bootstrap-sass says:

bootstrap-sprockets and bootstrap should not both be included in application.js.

For that reason, I removed bootstrap from my application.js.

I am also aware that the user guid for that gem says:

Do not use *= require in Sass or your other stylesheets will not be able to access the Bootstrap mixins or variables.

I still have this in my application.css.scss:

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

I read the gem documentation as meaning I am doing something wrong by keeping these require files in my css - but the gem documentation doesnt tell you what to use instead.

It says:

Then, remove all the *= require_self and *= require_tree . statements from the sass file. Instead, use @import to import Sass files.

How do you do this?

Entire gem file is copied below:

source 'https://rubygems.org'


# ------------------ Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'


# ------------------ Use postgresql as the database for Active Record
gem 'pg'

# ------------------ Use SCSS for stylesheets
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'

# ------------------ Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'


# ------------------ Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'

# ------------------ See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby

# ------------------ Use jquery as the JavaScript library
gem 'jquery-rails'


# ------------------ Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'


# ------------------ Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'


# ------------------ bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# ------------------ Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# ------------------ Use Unicorn as the app server
# gem 'unicorn'

# ------------------ Use Capistrano for deployment
# gem 'capistrano-rails', group: :development


# ----------- USERS

# ------------------ authentication

gem 'devise', '3.4.1'
gem 'devise_zxcvbn'
gem 'omniauth'
gem 'omniauth-oauth2', '1.3.1'
gem 'omniauth-google-oauth2'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'omniauth-linkedin-oauth2'
gem 'google-api-client', require: 'google/api_client'
# gem 'oauth2'
# ------------------ authorisation

gem 'pundit'

# ------------------ user roles

# ------------------ messaging

# ------------------ money

gem 'money-rails'

# ----------- CONTENT

gem 'state_machine'
gem 'acts_as_approvable'


# ------------------ file uploads
gem 'carrierwave'
gem 'mini_magick'
gem 'simple_form'

# ------------------ video
gem 'yt', '~> 0.25.5'
gem 'vimeo'

# ------------------ organisation
gem 'acts-as-taggable-on', '~> 3.4'

# ------------------ search

# ----------- OTHER

# ------------------ security

gem 'figaro'

# ------------------ performance
gem 'rails-observers'
gem 'high_voltage', '~> 2.4.0'

# ------------------ location

gem 'geocoder'
gem 'gmaps4rails'
gem 'underscore-rails'

gem 'country_select'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :production do
  gem "rails_12factor"
end

ruby "2.2.2"

Watching this video - https://gorails.com/episodes/styling-with-bootstrap-sass

The setup appears super simple, but this tutorial does not amend the file to remove references to require as the gem documentation suggests (but which I have not done) but this tutorial still works to get bootstrap working. Is there ANYTHING anyone can see that I might try? On the brink...

As you can see - I have been trying at this for more than a year. I've been to monthly meet ups, paid code mentors and hired contractors who haven't been able to help. Hoping for a miracle on this board. Bootstrap Sass with Rails 4

TRYING RESCUE SOLUTION BELOW:

So, I now have:

stylesheets as follows:

application.css

 *= require_tree .
 *= require_self
 */

custom.css.scss

@import "bootstrap-sprockets";
@import "bootstrap";

framework_and_overrides.css.scss:


@import "font-awesome-sprockets";
@import "font-awesome";
@import "bootstrap-slider";

javascript files as follows:

application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

application.html.erb:

<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => false %>
              <%= javascript_include_tag "application", media: 'all', "data-turbolinks-track" => false %>

gemfile:

gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3.5.1'
gem 'font-awesome-sass', '~> 4.4.0'
gem 'bootstrap-slider-rails'
gem 'bootstrap-datepicker-rails'

When I save all of this and complete the suggested steps, there is no change to the above. I click a link in the tab links across the top, the little box at the bottom of the screen says 'go to #[name of link tab] on this page, but nothing happens.

Community
  • 1
  • 1
Mel
  • 2,481
  • 26
  • 113
  • 273
  • What does your debug console (firebug for instance) have to say? I think somehow the files are not loaded properly. Can you confirm that the function datepicker is present in the rendered .js? (view source of your application homepage then click the link in the first – bo-oz Nov 24 '15 at 20:15
  • olark gem hasn't been updated in 3 years. I would remove it and run a test without it. – Elvn Nov 24 '15 at 23:25
  • When I click on view source on the home page, I get this error: $(document).on "focus", "[data-behaviour~='datepicker']", (e) -> - $(this).datepicker - format: "dd-mm-yyyy" - weekStart: 1 - autoclose: true – Mel Nov 25 '15 at 07:46
  • Although when I delete the project_dates.js file, I get no errors in the source viewer, but the tabs between the pages don't work - nothing happens when you click on them except that on the bottom of the screen shows the href name I gave each of the links – Mel Nov 25 '15 at 07:51
  • When I switch turbo links back on and reinstall that gem, bundle and restart the server, the links still don't work in the bootstrap tabs – Mel Nov 25 '15 at 08:10
  • Shouldn't this line "require_framework_and_overrides.css.scss" be "require framework_and_overrides.css.scss"? So without the first underscore? – benjamin Nov 28 '15 at 15:33
  • iirc, the lines for require jquery and jquery-ujs should be moved to the top before other required items (in that order), as the asset pipeline does not manage dependencies by itself. – benjamin Nov 28 '15 at 16:04
  • I tried moving jQuery and jQuery ujs to the top of the application.js. It doesnt throw any errors, but when i click on the link tabs, nothing at all happens. – Mel Nov 28 '15 at 21:51
  • I also tried removing the _ from the F&O css - no errors throw but nothing happens when i click the tab links – Mel Nov 28 '15 at 22:01
  • ok. then as a next step i would suggest to change "project_dates.coffee.js" to "project_dates.js.coffee", as you start by preprocessing the coffee script into js, not the other way around (the asset pipeline picks the preprocessors by looking at the different file extensions starting at the end) – benjamin Nov 29 '15 at 15:39
  • What else is in your Gemfile? Where is the coffee-rails gem? – benjamin Nov 29 '15 at 17:27
  • I once had the case, where everything was ok, but i missed to run rake assets:precompile for the right environment, before the newly introduced JS would show its magic. – benjamin Nov 30 '15 at 00:15
  • I just tried that command in my terminal and restarted, but the same problem persists, thanks anyway – Mel Nov 30 '15 at 00:17
  • if your "framework_and_overrides.css.scss" is located under "app/assets/stylesheets" you do not need the require directive in the "application.scss" file. btw, why is yours named "application.css.scss"? – benjamin Nov 30 '15 at 00:49
  • It is in my stylesheets folder. When I try deleting each of *= require_tree . *= require_self *= require framework_and_overrides.css.scss *= require bootstrap-datepicker, all the styling goes away. That can't be the right way to set this up. – Mel Nov 30 '15 at 09:05
  • When I try deleting just: *= require_tree . *= require_self, some of the styling stays but other bits aren't there. I think require must be integral to the set up – Mel Nov 30 '15 at 09:07
  • user2860931, "require_self" and "require_tree ." must stay in the file. just delete the line with "require framework_and_overrides.css.scss" (1). Have you renamed the other file to "project.js.coffee" (2). Do 1 and 2. – benjamin Nov 30 '15 at 16:37
  • I tried, js on the tabs doesnt work, i click a tab and nothing happens – Mel Nov 30 '15 at 19:51
  • @user2860931, I went over your bootstrap related questions. My answer walks you through to get tabs working without you having to write Javascript or Coffeescript. – benjamin Dec 01 '15 at 15:10
  • Hi Benjamin. Thanks so much! Im working through it all now. Stuck on step one (i have a problem with this: $ bundle exec bundle update, because of nokogiri) but I'm working through the steps to solve this. It looks so detailed and really really amazing of you to set it all out for me. I hope to finish the steps by tomorrow. I'll come back shortly. – Mel Dec 02 '15 at 08:55
  • @user2860931, just to cheer you up a little: Configuration Hell is so common, that even jokes exist around it http://www.c2.com/cgi/wiki?ConfigurationHell – benjamin Dec 02 '15 at 21:09
  • I can't tell you how happy I am to have found your help. Thanks for getting me back in the swing of it. I'm powering through your steps now. – Mel Dec 02 '15 at 22:14

2 Answers2

20

You are in configuration hell, and I have built a minimal working product to get you out of there. In order to achieve this, we tackle your problems in order of their appearance and do not try to solve them in parallel. This answer focuses on your first question and probably solves the others.

The copy of the project's Readme follows. In case you need access to the product, just let me know.

README

This is a demo application to help stackoverflowuser "user2860931" with issues as mentioned here.

Questions are listed in chronological order:

[Q1] November, 13 Rails with Bootstrap Tabs

[Q2] November, 22 Rails 4 - Bootstrap date picker

[Q3] November, 24 Rails - Bootstrap setup

Problem Description

Many configuration attempts have been made and a suboptimal development environment probably interrupted rails naming conventions by adding file extensions.

Versions Used

Rails 4.2.5

Steps To Create This Application By Yourself

First check for an appropriate rails version

$ rails --version
  1. Make sure the development environment (IDE) does not add file extensions by itself

  2. Creating a new rails application

    
    $ rails new rescue
    
  3. Locate the Gemfile of the application created under 1. and comment out the turbolinks gem entry Remove explanatory links for visual clarity

  4. Add the following lines to you Gemfile (one might want to fix gems to a particular version in order to avoid an application to stop working by an unplanned update, but this is another issue)

    
    gem 'bootstrap-sass' #,          '3.3.5.1'
    
  5. Run

    
    $ bundle exec bundle update
    $ bundle exec bundle install
    
  6. Create the file app/assets/stylesheets/custom.css.scss and add the following lines:

    
    @import "bootstrap-sprockets";
    @import "bootstrap";
    
  7. Add the following line to app/assets/javascripts/application.js

    
    //= require bootstrap
    

    IMPORTANT: This line has to follow the lines of jquery and jquery-ujs and before the require_tree directive so that the resulting file looks like:

    
    //= require jquery
    //= require jquery_ujs
    //= require bootstrap
    //= require_tree .
    
    NOTE: We have deleted the line for turbolinks, to reflect the production system's setup of user "user2860931" (stackoverflow).
  8. After saving all edited files, check whether the development environment has altered the file extensions (just to be sure this time)

    
      .
      ├── app
      │   ├── assets
      │   │   ├── images
      │   │   ├── javascripts
      │   │   │   └──application.js  
    │   │   └── stylesheets │   │   ├── application.css │   │   └── custom.css.scss
  9. Generate a minimal controller together with action and related view

    
    $ rails generate controller planets index
    
  10. Start the server

    
    $ rails s
    
  11. Visit in your browser

    
    http://localhost:3000/planets/index
    
  12. Last step to remove turbolinks completely

    1. View the HTML sourcecode of the site mentioned under 11.

    2. From file app/views/layouts/application.html.erb remove all data-turbolinks-track attributes so that the ERB code looks like:

      
      <%= stylesheet_link_tag    'application', media: 'all' %>
      <%= javascript_include_tag 'application' %>
      
    3. Repeat step 1. and note the difference

  13. Visit the file app/views/planets/index.html.erb and replace with your HTML as listed in [Q1]

  14. This setup renders your partials under the correct tabpanel. Be advised that that you are working in the development environment of Rails. A call to

    
    $ rake assets:clean
    $ rake assets:precompile
    

    could be needed in order to see changes once you deploy your main project (it should not be needed in Rails development mode).

    Tip: Use mock data files as arguments for the render function.

    
    app
    │   └── views 
    │   │  │   └── planets │   ├── _dummy00.html.erb │   ├── _dummy01.html.erb │   ├── _dummy02.html.erb │   ├── _dummy03.html.erb │   ├── _dummy04.html.erb │   ├── _dummy05.html.erb

and use calls to render 'planets/dummy05' in your HTML of Q1. Make sure each dummy file contains slightly different data, in order to be able to check for working tabs.

The mock-up result provides tabs via bootstrap and looks like this this.

Tabs are working as expectedexpected.

By providing you with the minimal working product, you should be enabled to bring your setup to a working state.

After all the preparation, adding a datepicker by just following the official documentation works, which answers Q2:

datepicker-picture

Sources Used To Provide This Answer

https://www.railstutorial.org/ by Michael Hartl

http://getbootstrap.com/components/#nav

http://getbootstrap.com/javascript/#tabs

http://getbootstrap.com/javascript/#tabs-usage

http://guides.rubyonrails.org/asset_pipeline.html

Community
  • 1
  • 1
benjamin
  • 2,185
  • 1
  • 14
  • 19
  • 1
    I was so hopeful about this. I can't start the server any more to check anything. I get this error: rails server bin/rails:6: warning: already initialized constant APP_PATH. I think that might be something to do with one of the steps I tried to get step 1 working. I'm going to try and solve that error and then come back and try this again. – Mel Dec 03 '15 at 10:02
  • @user2860931: If you are using this answer and really are creating a new project from scratch, then 1. stop the server 2. run the command "spring stop" 3. check with the command "ps aux | grep -i spring" if there is still some related process running. 4. start again at step (1) in the answer. You can do this. – benjamin Dec 03 '15 at 10:12
  • 1
    the server isn't running. i can't get it to start. – Mel Dec 03 '15 at 10:14
  • Are you working on your main project or on a dummy project right now? If the 2nd is the case, you cannot do damage and starting over is easy. But before deleting the project and start over you could try: "rake rails:update" iirc that helped me once. – benjamin Dec 03 '15 at 10:20
  • its my project. there are so many problems (i recall the pg problems with the first attempt at this project 2.5 years ago). I want to try to fix it because i don't think these issues are going to go away. – Mel Dec 03 '15 at 10:26
  • Currently getting this error with rake rails update. rake aborted! LoadError: cannot load such file -- nokogiri/nokogiri. I'm giving up for today. I'll try to solve that problem tomorrow. – Mel Dec 03 '15 at 10:27
  • Hi, i managed to get the server started, I can't get this working either. – Mel Dec 03 '15 at 10:49
  • @user2860931, I don't have so much time, but please join me in a chat: https://chat.stackoverflow.com/rooms/96877/misc – benjamin Dec 03 '15 at 11:14
  • 1
    @user2860931, ok - it looks like you are not online any longer. Here is how you should proceed: Do not try to incorporate my answer immediately into your main project, but rather build it separately and achieve success. **Only** then would you go into your main project, use your version control system and checkout a known working state and incorporate what you have achieved by building the dummy application. You **do not** try to get it working all in one go, **but** one thing at a time. – benjamin Dec 03 '15 at 11:50
  • I tried this in the new app i made 3 weeks ago. the only thing in it is a root page and this page that im working on now. i dumped the project I've been trying to get working for the last 2+ years. – Mel Dec 03 '15 at 18:54
  • Any way - thank you very much for your generosity with your time and effort. I think its pretty clear that I've failed at this and perhaps time to consider that coding inst going to work out for me. Thank you. – Mel Dec 03 '15 at 18:56
  • 1
    @user2860931 don't think that way. I'm programming since 14, or for ~18 years (I was a PHP programmer and switched to Ruby/Rails). Yet when I started with Rails and Bootstrap a few years ago, I had the same feeling and very similar frustrations. This is normal for about anyone learning something new. "No pain no gain", remember? :) Anyway I was going to do the exact same thing as @benjamin has done and go build a minimal working version. So I suggest: 1) @benjamin, what about putting this to GitHub for collaboration? 2) @user2860931 one step at a time is crucial, especially in the beginning.` – Halil Özgür Dec 03 '15 at 19:30
  • @user2860931 We have to change your perspective: how can you fail at coding, if what you do is configuring? Think about this until your mood gets boosted : ) – benjamin Dec 03 '15 at 23:30
  • @HalilÖzgür, so true. I am undecided about the github idea though, as following the answer should provide everybody with a basic bootstrap setup. But maybe I am missing your point entirely. – benjamin Dec 04 '15 at 00:58
  • @benjamin @user2860931 talked about some problems but it looks like they were fixed. In this case putting it to GitHub wouldn't be very meaningful. @user2860931, how about putting _your_ code to GitHub (unless it's private)?` – Halil Özgür Dec 04 '15 at 14:34
  • @HalilÖzgür Thank you for clarification. – benjamin Dec 04 '15 at 20:52
  • Hi benjamin - im still trying to solve my problems. i'm afraid even making a brand new app (again) didn't solve my issue but i hope your solution at least helps someone else – Mel Dec 05 '15 at 00:32
  • I am sorry to read that. What do you think about @HalilÖzgür's ideas? – benjamin Dec 05 '15 at 02:25
  • I have updated this answer again, as I gathered another piece of information. See a new answer here https://stackoverflow.com/questions/33852687/rails-4-bootstrap-date-picker/34102503#34102503 – benjamin Dec 05 '15 at 07:42
4

I encountered the same issue you do and found a solution (digging in the deep web) that worked for me. Try adding the requirements after the line require_tree . in the .css file, and in the .js file just the datepicker you use; as below:

application.css

 ...
 *= require_tree .
 *= require_self
 *= require bootstrap
 *= require bootstrap-datepicker
 */

application.js

...
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .
//= require bootstrap-datepicker

It is related to the asset pipeline of Ruby on Rails, you can go further on this topic in this page http://guides.rubyonrails.org/asset_pipeline.html , but first try changing the order of the lines.

JuanM.
  • 434
  • 1
  • 8
  • 19
  • Hi Juan, I tried to implement your suggestion. The first error was in the application.css.scss - which said couldn't find bootstrap. I tried replacing that with bootstrap sprockets and got the same error. I tried deleting the bootstrap reference (as I import both bootstrap sprockets and bootstrap through my framework and overrides css file. That loads, but the js doesn't work on the tabs. – Mel Nov 29 '15 at 21:18
  • 1
    There is no need to download a file when using the rails gem – benjamin Dec 05 '15 at 08:36