Skip to content Skip to sidebar Skip to footer

Javascript Not Running On Heroku With Rails 3.1

I've migrated a rails 3.0 app to 3.1 on Heroku. It's running on the cedar stack and everything is fine except that the app's javascript won't run. The application.js file is compil

Solution 1:

Open your application.rb file and make sure your Bundler require statement looks like the following:

Bundler.require *Rails.groups(:assets)

By default it looks like

# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line# Bundler.require(:default, :assets, Rails.env)

Solution 2:

Manually precompiling worked for me.

bundle exec rake assets:precompile before you push to heroku.

Solution 3:

Solution 4:

I had some Javascript problems (server-side on Heroku, locally everything was fine) that went away when I * moved all my Javascript into a separate file instead of application.js * removed require_tree from application.js and instead called up every javascript I wanted by name * removed bootstrap.js from my app/assets/javascript folder

My guess is that compilation somehow screws things up.

Solution 5:

I hope you did a local pre-compilation of assets before your latest Heroku push (as advised in one of the responses above). Please check if your system is blocking the execution of JavaScripts. For this, open up the console while you are on your Heroku app, and check for exceptions. In case you see exceptions related to JavaScripts being blocked, that could be the issue. In my case, the same happened, and unfortunately, I was not able to do anything about it, as I didn't have admin privileges.

Post a Comment for "Javascript Not Running On Heroku With Rails 3.1"