1
votes

I'm trying to use a Foundation 5 Orbit slider in my rails 4 app and it works perfectly in the develop environment but not in production on Heroku. When I use Chrome's Developer Tools to see what's going on it says it cannot find foundation.js. On the page itself the first image shows but the navigation controls and next images do not.

I'm using Foundation via the 'foundation-rails' gem (5.0.2). I've tried manually placing the foundation.js file into the vendor/assets/javascripts folder as well as the app/assets/javascripts folder, but neither works.

My applications.js file looks like this:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require foundation
$(function(){ $(document).foundation(); });

and I have the following in my application.html head:

<%= javascript_include_tag "application" %>
<%= javascript_include_tag "vendor/modernizr" %>
<%= javascript_include_tag "//code.jquery.com/jquery-1.10.2.min.js" %>

and in the body:

<%= javascript_include_tag "foundation" %>

I've tried multiple things, such removing the application js reference from the head and putting it into the body, removing the foundation JS reference from application.js and the body of application.html, but none seem to work.

2

2 Answers

1
votes

How are you precompiling your assets? According to Heroku's Rails Asset Pipeline docs You either need to locally run

$ bundle exec rake assets:precompile

and then push to heroku, or (and this is what I recommend and use, myself), enable the Heroku Labs: user-env-compile by running this command:

$ heroku labs:enable user-env-compile -a myapp

This will tell Heroku to precompile your assets for you every time you push to Heroku (this cuts down on the code you check in).

Additionally, you do not require javascript_include_tags for jQuery nor Foundation if you are including them via application.js.

0
votes

is everything else working for foundation apart from the orbit? if not, try to remove modernizr script from the html head, move the modernizr file into config/vendor/javascript, add modernizr in the require list before tree in the application.js file, precompile your assets and push to heroku again. worked for me