Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

I have added the above into my application.html.erb file, but I seem to not be able to use bootstrap or jQuery still. Can you please explain why rails doesn't allow linking in the html file? Why must we use gems?

like image 873
kchow Avatar asked Jan 29 '26 17:01

kchow


1 Answers

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

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
like image 174
Sharvy Ahmed Avatar answered Feb 01 '26 06:02

Sharvy Ahmed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!