This question seems to have been asked 30 different ways, and I've attempted all of the solves with no luck.
Rails 4 app that runs fine locally, but when deployed to heroku (Cedar), the javascript is not executing. Process I'm going through:
1) RAILS_ENV=production bundle exec rake assets:precompile 2) git add, then commit 3) git push heroku master
I've also tried clobbering the assets on both heroku and my local machine.
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_assets = true
config.assets.compress = true
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
config.assets.digest = true
config.assets.precompile += %w( '.woff', '.eot', '.svg', '.ttf' )
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
application.rb
config.assets.version = '4.0'
config.assets.enabled = true
config.before_configuration do
env_file = File.join(Rails.root, 'config', 'local_env.yml')
YAML.load(File.open(env_file)).each do |key, value|
ENV[key.to_s] = value
end if File.exists?(env_file)
end
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => ENV['POSTMARK_API_KEY']}
config.assets.initialize_on_precompile = false
config.middleware.use Rack::Attack
I've also tried adding config.assets.compile = true
application.js
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require masonry/jquery.masonry
//= require masonry/jquery.imagesloaded.min
//= require masonry/jquery.infinitescroll.min
//= require masonry/modernizr-transitions
//= require underscore
//= require gmaps/google
//= require_tree .
When I run the app on heroku, I can see the javascript in through the developer tools:
..but the js is not executing. Where am I going wrong here?
Try moving //=require Turbolinks
to the very bottom of your application.js and see if that doesn't help. Also, you can try turning off turbolinks. Turbolinks is cool, but doesn't always play nice with others.
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.