How can I include jQuery / bootstrap / javascript in my rails app with CDN?

I know you can add jQuery and bootstrap with gems, assets and application.css and application.js file. However, I would like to be able to add these files via the CDN.

<link rel="stylesheet"             href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

      

I added this to my application.html.erb file but can't seem to use bootstrap or jQuery yet. Could you please explain why rails don't allow you to link html files? Why should we use gems?

+3


source to share


3 answers


You need to add the js file before closing the body tag :



<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

      

+1


source


I think you need to make sure you are calling your JQuery before uploading files

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

      



If you want to make a cdn call for both Jquery and Bootstrap, these are the links: fooobar.com/questions/2226549 / ... and fooobar.com/questions/10979 / ...

0


source


Use jquery cdn gem

In your layout

<%= include_jquery cdn: :google %>

      

0


source







All Articles