Since many days I tried to understand why a simple link like this:
link_to 'My Link', my_path(format: :js), remote: true
always returned the full HTML document instead of executing the javascript located in file.js.erb:
alert('hello world')
[...]
After hours of debugging, I discovered why:
When I rename my main layout file, for example : application.haml
, it displays the full HTML document:
Started GET "/my_path/2.js" for 127.0.0.1 at 2016-03-05 12:28:20 +0100 Processing by MyController
When I rename my main layout file, for example : application.html.haml
, it correctly executes javascript and launches a welcome popup:
Started GET "/my_path/8.js" for 127.0.0.1 at 2016-03-05 12:28:34 +0100 Processing by MyController
Why is there a difference in JavaScript behavior according to the different names of my layout?
source share