This is a very strange problem. I've got a rails app in which I am replacing one partial on the page with another using UJS. Recently, it stopped worked, so I started logging throughout the process to see where it broke. Here's what I found:
- After the link is clicked, the rails console tells me that everything rendered, including all the partials, and returns 200 OK.
- A puts in the controller actions returns fine
- A puts in the respond.do block returns fine
- A puts in the .js.erb file returns fine
This means it's getting all the way to running the .js.erb file and evaluating the ruby with no errors. But here's what's weird - none of the javascript is executing. When I run an alert('hello?') in the .js.erb file, it's not executing.
Has anyone ever run into this problem before? It seems exceedingly strange that it would run the erb evaluation but not the js. And no errors appear in the js console either.
For the record I have: cleared the cache, restarted the browser, restarted the rails app, and nothing changed.
Sample code:
# view
link_to 'example', some_path, :remote => true
# controller
respond_to do |format|
format.js
end
# .js.erb file
alert('this never shows up');
<% puts 'this shows up in the rails console' %>
Thanks soo much to anyone who can shed a bit of light on this strange problem!