Search code examples
javascriptruby-on-rails-4herokuzurb-foundation-5

Javascripts not working on Heroku Rails 4.2 deploy with Zurb Foundation 5, but work in development


I'm running Rails 4.2.3 with the 'foundation-rails' 5.5.2 gem and am not able to get it running on Heroku. My app is working fine locally, but when trying to deploy my app to Heroku with Foundation 5 the javascripts are not loading.

The CSS looks ok on Heroku, but things like modals are not working, and the console doesn't show that there are any javascripts running that were specified in my application.js file.

Modernizr.js and Jquery-2.1.4 are running

I'm not seeing any errors anywhere, and I have precompiled assets using bundle exec rake assets:precompile and the assets appear to have been precompiled.

How do I get the javascripts to load so that the page will work properly?

application.js:

//= require jquery
//= require jquery_ujs
//= require jquery.serializeJSON
//= require jquery.bind_with_delay
//= require_tree .
//= require_self
//= require gifffer.min
//= require imagesloaded.min
//= require google.jsapi
//= require foundation
//= stub bookmarklet/modal_bookmarklet
$(function() { 
  $(document).foundation();
});

production.rb

config.cache_classes = true

config.eager_load = true

config.consider_all_requests_local       = false
config.action_controller.perform_caching = true

config.serve_static_files = true

config.assets.js_compressor = :uglifier

config.assets.compile = true

config.assets.digest = true

gemfile

source "https://rubygems.org"

gem "rails", "4.2.3"
gem "unicorn"
gem "mysql2", ">= 0.3.14"
gem "pg"
gem "thinking-sphinx", "~> 3.1.2"
gem "jquery-rails"
gem "dynamic_form"
gem "exception_notification"
gem "bcrypt", "~> 3.1.2"
gem "nokogiri", "= 1.6.6.2"
gem 'mini_portile', '~>0.6.2'
gem "htmlentities"
gem "rdiscount"
gem "oauth"
gem "mail"
gem 'metainspector', :git => 'https://github.com/jaimeiniesta/metainspector.git'
gem 'material_icons'
gem "bower-rails","~> 0.9.2"
gem 'launchy'
gem 'sass', '~> 3.4.15'
gem 'foundation-rails', '~> 5.5.2'
gem 'compass', '~>1.0.3'
gem "uglifier", ">= 1.3.0"
gem 'coffee-rails', '~> 4.1.0'
gem 'modernizr-rails', '~>2.7.1'
gem 'jbuilder', '~> 2.3.0'
gem 'multi_json', '~>1.11.1'

gem 'rails_12factor'
gem 'paperclip', :git => "git://github.com/thoughtbot/paperclip.git"
gem 'aws-sdk'
gem 'figaro'
gem 'omniauth-facebook'

gem 'pg_search'
gem 'kaminari'
gem 'ejs'

gem 'yt', '~> 0.25.0'

group :doc do
    gem 'sdoc', require: false
end

group :test, :development do
  gem "rspec-rails", "~> 3.3.2"
  gem "machinist"
  gem "sqlite3"
  gem "faker"
  gem 'annotate'
  gem 'better_errors'
  gem 'binding_of_caller'
end

edit It looks like I'm getting an error that says "Uncaught TypeError: $(...).foundation is not a function". I'm not sure if this is related to Heroku or my configuration. Why would this work locally, and not on Heroku?


Solution

  • You have your require_self call before you load the foundation JS and you are trying to use the foundation JS in your manifest file. Try moving the require_self directive after all of your other directives.