I have such a code in my "create" method:
respond_to do |format| if user.save() format.html {redirect_to(:action => "show")} else format.js end end
So if save() is successful I want full redirect to a different page. If not successful then no redirect, just show user an ajax message about the error on the same page.
My form is with 'data-remote="true"'.
And my "create.js.erb" is simple: document.getElementById("warn").innerHTML = "<p>Error</p>";
Save() works fine but I get no redirection. The same page stays without change. And if save() is impossible then format.js works fine. But why redirection doesn't work?