i was wondering how can i create my own custom validates_ function. e.g. i am validating email adresses on a lot of places and would like to achieve the following class User validates_email :email end does some has any hints? with the same technique i would also like to do the following class User strip_attributes :firstname, :lastname end this would automatically ensure that the attributes firstname and lastname are stored always without preceeding and trailing spaces. thanks for your help... -- 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 -~----------~----~----~----~------~----~------~--~---
On Nov 24, 9:12 am, Michal Gabrukiewicz <rails-mailing-l...@andreas- s.net> wrote:> i was wondering how can i create my own custom validates_ function. e.g. > i am validating email adresses on a lot of places and would like to > achieve the following > > class User > validates_email :email > end > > does some has any hints? > > with the same technique i would also like to do the following > > class User > strip_attributes :firstname, :lastname > end > > this would automatically ensure that the attributes firstname and > lastname are stored always without preceeding and trailing spaces. > thanks for your help... > -- > Posted viahttp://www.ruby-forum.com/.these are good http://www.railsjitsu.com/ruby-on-rails/writing-your-own-custom-validators/ http://paulsturgess.co.uk/articles/show/33-how-to-write-custom-validation-in-ruby-on-rails --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 24, 9:12 am, Michal Gabrukiewicz <rails-mailing-l...@andreas- s.net> wrote:> i was wondering how can i create my own custom validates_ function. e.g. > i am validating email adresses on a lot of places and would like to > achieve the following > > class User > validates_email :email > end > > does some has any hints? > > with the same technique i would also like to do the following > > class User > strip_attributes :firstname, :lastname > end > > this would automatically ensure that the attributes firstname and > lastname are stored always without preceeding and trailing spaces. > thanks for your help... > -- > Posted viahttp://www.ruby-forum.com/.better no 404 http://www.railsjitsu.com/writing-your-own-custom-validators --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks .. this one is exactly what i need.> > http://www.railsjitsu.com/writing-your-own-custom-validators-- 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 -~----------~----~----~----~------~----~------~--~---