I have a form that renders its errors via AJAX. The form is properly sending a remote request, and the server is returning javascript:
(function() {
$("#main").fadeIn(". . .");
}).call(this);
Unfortunately, nothing actually renders in the browser. At first I thought there must be an error in the js code, but when I copy and paste this code into the Firebug console, it properly fades in the new content. The problem seems to be that the browser isn't running the code in the first place. What might cause this problem?
For reference, here's my form markup:
= simple_form_for @user, html: {multipart: true}, remote: true do |f|
. . .
.btn.btn--positive = f.submit
And here's the controller action:
def update
if @user.update(user_params)
redirect_to @user, notice: t('shared.notices.item_was_successfully_updated', item: @user.name)
else
render layout: 'transition.js.coffee', action: 'edit'
end
end
The error occurs when the update doesn't validate and Rails runs the line render layout: 'transition.js.coffee', action: 'edit'
.