Playing with custom validations (i need to start doing this) This works... def validate errors.add :date_of_birth, ''is not a valid date'' if Chronic.parse(date_of_birth.to_s).nil? end Trouble is when the form is re-rendered it''s lost the users original selection - how do i fix it up? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thinking this through maybe this is the problem <td> <%= date_select ''enquiry'', ''date_of_birth'', :order => [:day, :month, :year], :start_year => 1950, :end_year => 2000, :include_blank => true %> is the include blank the problem (maybe it''s getting blanked on the re-render)? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
bingo bob wrote:> > thinking this through maybe this is the problem > > > <td> <%= date_select ''enquiry'', ''date_of_birth'', :order => [:day, > :month, :year], :start_year => 1950, :end_year => 2000, :include_blank > => true %> > > is the include blank the problem (maybe it''s getting blanked on the > re-render)?this looks like the problem to me - but how do i fix it? I''d like to show a blank on the initial form but not when a validation fails and the form is shown again (the user should see the original selection? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No, the include_blank is not the problem I think. date_select automatically selects the value given in @enquiry.date_of_birth... The problem must be somewhere else. Are you sure @enquiry is not reset? A mistake I used to make is to redirect from the create to the new action instead of directly rendering the new template from the create action when rerendering the form. anyway, this is just a guess... I need to see how exactly you are rendering the form. On Apr 10, 11:31 am, bingo bob <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> bingo bob wrote: > > > thinking this through maybe this is the problem > > > <td> <%= date_select ''enquiry'', ''date_of_birth'', :order => [:day, > > :month, :year], :start_year => 1950, :end_year => 2000, :include_blank > > => true %> > > > is the include blank the problem (maybe it''s getting blanked on the > > re-render)? > > this looks like the problem to me - but how do i fix it? > > I''d like to show a blank on the initial form but not when a validation > fails and the form is shown again (the user should see the original > selection? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---