Question

Basics: Rails 4 Ruby 2.0

We are stumped with why we can't get Bootstrap Javascript to work on Heroku when it works fine on our dev machine. We had it working with modals, but when we switched to tabs it stopped.

Application.js

//= require analytics
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree 

production.rb

Entreuse::Application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.assets.version = '1.0'
config.log_level = :info

development.rb

Entreuse::Application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local       = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
config.assets.precompile += %w( .svg .eot .woff .ttf)

gemfile

gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem "haml", "~> 4.0.5"
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem "bootstrap-sass", "~> 3.1.1.0"
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'font-awesome-sass', '~> 4.0.3.1'

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

group :development, :test do
gem 'sqlite3'
end

group :production do
gem 'pg'
gem 'rails_12factor'
end

App on Heroku http://www.entreuse.com/

Any insights would be much appreciated.

Thanks!

Was it helpful?

Solution

We got this fixed!

The problem was with the analytics //= require analytics

The error we were getting had to do with the fact that analytics.js.coffee was being included at the top before jQuery was included - it should be at the bottom after jQuery is included. So when it used the dollar sign method at the top of the js file, jQuery hadn't been defined yet.

This post was very helpful: Rails 4 turbolinks with Google Analytics

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top