3

My javascript is not making it to my heroku app even though my application.html.haml file has: = javascript_include_tag "application". I threw in an alert to check if any js is making it there but no cigar. I also checked in firebug and the javascript isn't being sent to the browser what-so-ever. Any ideas?

application.js

//= require jquery
//= require jquery_ujs
//= require_tree .
//= require jquery_nested_form
//= require jquery-fileupload
//= require autoNumeric
//= require lightbox

alert('test?');

Production.rb

MyMyApp::Application.configure do
  config.force_ssl = true
  config.cache_classes = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true (I tried false)
  config.assets.compress = true
  config.assets.compile = true
  config.assets.digest = true
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
end

ruby '2.0.0'

gem 'rails', '3.2.13'

3
  • 1
    Does your application.js have the alert code inside or not if you do View Source on Heroku? Commented Oct 16, 2013 at 14:15
  • if you want the alert to appear you have to add //= require_self Commented Oct 16, 2013 at 14:31
  • Not necessary the alert appears in development. Commented Oct 17, 2013 at 18:04

2 Answers 2

1

There are many problems with asset pipeline and heroku. Check this linke

https://devcenter.heroku.com/articles/rails-asset-pipeline

Or simply put into config/application.rb line:

config.assets.initialize_on_precompile = false

This should solve your problems cheers.

Sign up to request clarification or add additional context in comments.

2 Comments

can you post your javascript include tag from application layout ? and config/environments/production.rb files
I added the production.rb
0

2 things:

-> Try to call when document is ready

$(document).ready(function() {
    alert('hello');
});

-> Try to precompile assets before pushing to Heroku:

in your production.rb:

config.serve_static_assets = true
config.assets.compile = true

in your cmd:

> rake assets:precompile
> git push heroku master

1 Comment

it is alert it will work anyway. I think the problem is that heroku is not serving his assets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.