hleinar-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org
2007-May-29 07:41 UTC
Validates that one date is before another one
How could I use validation in Ror to validate that one date is before the other date ? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hleinar-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org wrote:> How could I use validation in Ror to validate that one date is before > the other date ? > > Thanks.In your model do: def validate errors.add(:some_attribute, "some message") if date_one > date_two end Depending on the logic you need to do nil checks as well. I am pretty sure you can''t compare a nil object with a date object. -- 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 -~----------~----~----~----~------~----~------~--~---
hleinar-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org
2007-May-29 08:07 UTC
Re: Validates that one date is before another one
Thanks for the answer. On 29 mai, 10:05, Ben Johnson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> hlei...-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org wrote: > > How could I use validation in Ror to validate that one date is before > > the other date ? > > > Thanks. > > In your model do: > > def validate > errors.add(:some_attribute, "some message") if date_one > date_two > end > > Depending on the logic you need to do nil checks as well. I am pretty > sure you can''t compare a nil object with a date object. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can put custom validations in the "validate" method on your model. You can use any ruby code there to do validations. Look on the web or the source of existing validations for examples on how to format the error objects. Michael On May 29, 12:41 am, "hlei...-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org" <hlei...-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org> wrote:> How could I use validation in Ror to validate that one date is before > the other date ? > > Thanks.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, im trying to unsubscribe me to the list, for one reason (i think the server is catching for some spam rule) i cant unsubscribe me from the website. thnx for the help. ----------------------- David Gutiérrez C. Danilo Black : WebMedia david-/Y4LLybpLDmMe3Hu20U6GA@public.gmane.org MSN: djonathangc-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org tel. +52 (81) 81 73 70 53 Blvd. Antonio L. Rdz. 2100, Col. Santa María Monterrey, N.L. México, 64650 From: MichaelLatta <lattam-ee4meeAH724@public.gmane.org> Reply-To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Date: Tue, 29 May 2007 07:36:11 -0700 To: "Ruby on Rails: Talk" <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Subject: [Rails] Re: Validates that one date is before another one You can put custom validations in the "validate" method on your model. You can use any ruby code there to do validations. Look on the web or the source of existing validations for examples on how to format the error objects. Michael On May 29, 12:41 am, "hlei...-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org" <hlei...-CnXOeebvsI53K8eIWKoEHQ@public.gmane.org> wrote:> How could I use validation in Ror to validate that one date is before > the other date ? > > Thanks.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---