I''m trying to create a page that has both a list of users [A] and edits them in another column [B] in the same page. I''m able to create the link that open a div to do [B] but what I''m not able to figure out yet is how to handle validation errors in [B] since all the examples (and movies) I''ve seen deal with data that does not seemt o need validation. Can anybody guide me throguh what would be the Rails way? ------------------------ | USERS LIST | ------------------------ | ---------- | ------- | | | [A] | | | [B} | | | ---------- | ------- | ------------------------ Thanks in advance, -- Adrian Esteban Madrid aemadrid-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I agree that most of the examples seem a little void of error handling. I''m looking at a similar situation and am thinking about having the response for the ajax form submission respond with the same form (populated with error messages and highlighting on error) which is placed in [B]. Also I''m going to write a little javascript to execute on the form submission completion. which will ''refresh'' list in div [A] using a separate ajax call. I''m not sure that this would be the Rails way, however. On Thursday 02 June 2005 12:58 am, Adrian Madrid wrote:> I''m trying to create a page that has both a list of users [A] and edits > them in another column [B] in the same page. I''m able to create the link > that open a div to do [B] but what I''m not able to figure out yet is how to > handle validation errors in [B] since all the examples (and movies) I''ve > seen deal with data that does not seemt o need validation. Can anybody > guide me throguh what would be the Rails way? > > ------------------------ > > | USERS LIST | > > ------------------------ > > | ---------- | ------- | > | > | | [A] | | | [B} | | > | > | ---------- | ------- | > > ------------------------ > > Thanks in advance,-- Micah Alles micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org 616-776-6020 Software Journeyman Atomic Object LLC _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
We had this same issue a few weeks ago. I modified form_remote_tag to accept an :update_on_error argument, as well as the usual :update argument. Now, when a controller is returning data for an ajax call, it sets @headers["X-Error"] = "true" if there was an error, and the content goes in the other div. It''s obviously not the "rails way", since it involves modifying form_remote_tag... but all in all, it''s very clean :] Tyler On 6/6/05, Micah Alles <micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org> wrote:> > I agree that most of the examples seem a little void of error handling. > > I''m looking at a similar situation and am thinking about having the response > for the ajax form submission respond with the same form (populated with error > messages and highlighting on error) which is placed in [B]. > Also I''m going to write a little javascript to execute on the form submission > completion. which will ''refresh'' list in div [A] using a separate ajax call. > > I''m not sure that this would be the Rails way, however. > > On Thursday 02 June 2005 12:58 am, Adrian Madrid wrote: > > I''m trying to create a page that has both a list of users [A] and edits > > them in another column [B] in the same page. I''m able to create the link > > that open a div to do [B] but what I''m not able to figure out yet is how to > > handle validation errors in [B] since all the examples (and movies) I''ve > > seen deal with data that does not seemt o need validation. Can anybody > > guide me throguh what would be the Rails way? > > > > ------------------------ > > > > | USERS LIST | > > > > ------------------------ > > > > | ---------- | ------- | > > | > > | | [A] | | | [B} | | > > | > > | ---------- | ------- | > > > > ------------------------ > > > > Thanks in advance, > > -- > Micah Alles micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org > 616-776-6020 > Software Journeyman Atomic Object LLC > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >
Hi, Have a look at this patch: http://dev.rubyonrails.com/ticket/1217 Thomas Am 06.06.2005 um 21:58 schrieb Tyler Kiley:> We had this same issue a few weeks ago. I modified form_remote_tag to > accept an :update_on_error argument, as well as the usual :update > argument. Now, when a controller is returning data for an ajax call, > it sets @headers["X-Error"] = "true" if there was an error, and the > content goes in the other div. > > It''s obviously not the "rails way", since it involves modifying > form_remote_tag... but all in all, it''s very clean :] > > Tyler > > On 6/6/05, Micah Alles <micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org> wrote: > >> >> I agree that most of the examples seem a little void of error >> handling. >> >> I''m looking at a similar situation and am thinking about having >> the response >> for the ajax form submission respond with the same form (populated >> with error >> messages and highlighting on error) which is placed in [B]. >> Also I''m going to write a little javascript to execute on the form >> submission >> completion. which will ''refresh'' list in div [A] using a separate >> ajax call. >> >> I''m not sure that this would be the Rails way, however. >> >> On Thursday 02 June 2005 12:58 am, Adrian Madrid wrote: >> >>> I''m trying to create a page that has both a list of users [A] and >>> edits >>> them in another column [B] in the same page. I''m able to create >>> the link >>> that open a div to do [B] but what I''m not able to figure out yet >>> is how to >>> handle validation errors in [B] since all the examples (and >>> movies) I''ve >>> seen deal with data that does not seemt o need validation. Can >>> anybody >>> guide me throguh what would be the Rails way? >>> >>> ------------------------ >>> >>> | USERS LIST | >>> >>> ------------------------ >>> >>> | ---------- | ------- | >>> | >>> | | [A] | | | [B} | | >>> | >>> | ---------- | ------- | >>> >>> ------------------------ >>> >>> Thanks in advance, >>> >> >> -- >> Micah Alles micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org >> 616-776-6020 >> Software Journeyman Atomic Object LLC >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> >> >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Thanks for replying. I have finally figured out a way to do this. Part of my problem was that I was using partials to render this B area and that wasn''t handling well the flash for some reason. I moved to full actions and now it''s working great. I changed all the scaffold actions (with the exception of index and list) to ajax_* (ajax_edit, ajax_update, etc) and using "layout :define_layout" in the controller I can say if the action name starts with "ajax_" don''t do a layout. I also make ajax_edit and ajax_new work with remote form tags so as to refresh in it''s own div and refresh the list in A when they are complete. So far it''s been working fine for me. Let me know if any of this code will help you at all. Adrian Madrid Micah Alles wrote:>I agree that most of the examples seem a little void of error handling. > >I''m looking at a similar situation and am thinking about having the response >for the ajax form submission respond with the same form (populated with error >messages and highlighting on error) which is placed in [B]. >Also I''m going to write a little javascript to execute on the form submission >completion. which will ''refresh'' list in div [A] using a separate ajax call. > >I''m not sure that this would be the Rails way, however. > >On Thursday 02 June 2005 12:58 am, Adrian Madrid wrote: > > >>I''m trying to create a page that has both a list of users [A] and edits >>them in another column [B] in the same page. I''m able to create the link >>that open a div to do [B] but what I''m not able to figure out yet is how to >>handle validation errors in [B] since all the examples (and movies) I''ve >>seen deal with data that does not seemt o need validation. Can anybody >>guide me throguh what would be the Rails way? >> >>------------------------ >> >>| USERS LIST | >> >>------------------------ >> >>| ---------- | ------- | >>| >>| | [A] | | | [B} | | >>| >>| ---------- | ------- | >> >>------------------------ >> >>Thanks in advance, >> >> > > > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >-- Adrian Madrid HyperX Inc. Mobile: 801.815.1870 Office: 801.566.0670 aemadrid-kSB444ljgzMmlAP/+Wk3EA@public.gmane.org www.hyperxmedia.com 9000 S. 45 W. Sandy, UT 84070 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails