On Tue, Apr 16, 2013 at 7:15 PM, Wins Lin <li...@ruby-forum.com> wrote:
> 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?

If this is responding to an AJAX request, what do you think would be
the result of redirecting the AJAX request?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to