timpone
timpone

Reputation: 19979

getting bootstrap-sass gem and rails to work with existing project

I'm trying to integrate bootstrap into a current rails project and am having a difficult type installing. Specifically, I seem to be having a problem with the javascript. I have added to application.js:

//= require bootstrap

But I get the following error:

enter image description here

These are referenced in bootstrap.js.coffee and I can get rid of the errors by clearing this file out. Here are the contents:

jQuery ->
  $("a[rel=popover]").popover()
  $(".tooltip").tooltip()
  $("a[rel=tooltip]").tooltip()

There is discussion about loading the individual modules but it's not clear to me if I should be doing this or whether I need to be doing this. https://github.com/thomas-mcdonald/bootstrap-sass

I'd really like to be able to add bootstrap to this currently existing project. Any help is appreciated.

thx

Upvotes: 0

Views: 1020

Answers (2)

hjblok
hjblok

Reputation: 2966

First of all bootstrap requires jQuery. For Rails you can use the jquery-rails gem which provides the latest version of jQuery.

Then within your application.js you can load the required Javascripts with

//= require jquery
//= require jquery_ujs
//= require bootstrap

//= require_tree .
//= require_self

As neon mentions the load order of the scripts is important. You should load jquery first, then load bootstrap. At this point you can load all other scripts in the current directory with require_tree . (which probably contains your bootstrap.js.coffee).

Upvotes: 0

neon
neon

Reputation: 2821

You should make sure you have bootstrap.js or bootstrap.min.js from the Twitter Bootstrap Docs and then require it as you did. I think your issue is that you have yet another file named bootstrap.js.coffee. Try changing the name of it and requiring it along with //=require bootstrap.

Upvotes: 1

Related Questions