On Thu, May 9, 2013 at 11:59 AM, Sumit Srivastava <[email protected]> wrote: > Hi, > > I have a partial which is being rendered in a view in controller A. This > partial has a form which calls 'update' action in controller B. If update > fails I have the render back the original view again with the proper errors. > I used, > > render :action => :show > > This show action is actually is that of controller B but the call being ajax > it is not loaded and the original view continues to be displayed but the > errors are not being shown. > > The problem is I am not able to detect the errors being received if any.
Let me see if I understand. 1) A is a controller that renders an standard HTML view of some type (ERB, HAML, etc). 2) B is a controller that is called by the page A renders as AJAX, returning JSON data. If controller B fails for some reason, you need to inform your client side application of the failure, typically this is also done be returning JSON with an error code and message, plus any other information needed for the client-side application to recover gracefully (and inform the user if necessary). Meanwhile, controller B should also be logging information about it's state to the Rails.logger, thus giving you a place to put information for later debugging, if necessary. So: any controller called by AJAX should *always* return JSON, either the expected result, or an error object. -- 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 [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

