Do we have access to all of the controller variables in RJS so that we
can make decisions within that template as they relate to errors that
may have occurred on a form_to_remote call?
I have a form_to_remote call that I want to either update a DIV on my
page (success) or redisplay the entry form with error messages (some
I’m pretty sure I can set up two RJS files, one for each case. But what
about having one RJS template that is capable of deciding which set of
I don’t think so, but I thought I would ask.
Got this to work but it feels hokey.
My controller action renders to an RJS action, like so:
flash[:error] = ‘The email address that you entered was not valid’
return render :action => ‘proof_failed’
Then proof_failed.rjs does:
page.redirect_to :action => ‘proof_form’
specified in the form_to_remote call. Then the redirect just sends me
back to the entry form which displays my error.
A bit roundabout.
I’m thinking about a mixed - mode thing where you could use the
traditional return method to handle errors and only respond to the AJAX
query upon success. But that would leave a bunch of AJAX requests
hanging which wouldn’t be good.
Hope this helps someone.