Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails JavaScript views not working in production

I'm having an unexplainable issue with my Rails app. I'm using a lot of JavaScript in all parts of the app. In development everything is working just fine, but in production it seems that the code in my javascript views is not executed.

This is particularly odd because all other JavaScript on the page works great. Custom tabs with JavaScript work. Even my custom made calendar works as expected. The only things that do not work are remote links which trigger views ending with .js.coffee.

My webkit inspector returns this when clicking a remote link: http://cl.ly/Ihyf

However, when looking at the response tab of that request it shows me nothing: http://cl.ly/Ihxs

Furthermore, the console does not show any errors. It's as if my new.js.coffee is just empty.

The view that is being called contains some simple JavaScript to show a modal:

$('#modal_container').html("<%=j render 'form' %>")
$('#modal_container').modal()

In development mode, all views load properly. I also ran rake:assets:precompile multiple times, but that didn't seem to help.

like image 495
Bram Jetten Avatar asked Feb 19 '23 12:02

Bram Jetten


1 Answers

You should move coffee-rails gem from the :assets group to the main group.

like image 72
Vasiliy Ermolovich Avatar answered Mar 04 '23 12:03

Vasiliy Ermolovich