Hello all, I''m trying to directy call validation methods in the controller (for instance account.validates_format_of ''e-mail'', :with => ''/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'', :within => 5..199) but it does not work. It always gives the error "undefined method `validates_format_of'' ". I need to do this because I allow the user to add new columns to a model and I only know it''s type (string, int or date) at runtime. Can anyone help me? Thanks. Best regards, Migrate -- 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 -~----------~----~----~----~------~----~------~--~---
Place validates_format_of inside your account model and have your controller pass your validation string to it. On 6/8/07, Migrate <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello all, > I''m trying to directy call validation methods in the controller (for > instance account.validates_format_of ''e-mail'', :with => > ''/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'', :within => 5..199) but it > does not work. It always gives the error "undefined method > `validates_format_of'' ". > > I need to do this because I allow the user to add new columns to a model > and I only know it''s type (string, int or date) at runtime. > > Can anyone help me? > > Thanks. > Best regards, > Migrate > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Amos King A. King Software Development and Consulting, L.C. http://dirtyInformation.com -- Looking for something to do? Visit http://ImThere.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 -~----------~----~----~----~------~----~------~--~---
> because I allow the user to add new columns to a modelin 99.9% of cases you should not modify domain model at runtime. .1% reserved for barely realistic approach, I never heard about. would you explain a bit what is the problem you trying to solve that way? On Jun 8, 11:08 am, Migrate <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello all, > I''m trying to directy call validation methods in the controller (for > instance account.validates_format_of ''e-mail'', :with => > ''/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'', :within => 5..199) but it > does not work. It always gives the error "undefined method > `validates_format_of'' ". > > I need to do this because I allow the user to add new columns to a model > and I only know it''s type (string, int or date) at runtime. > > Can anyone help me? > > Thanks. > Best regards, > Migrate > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Hello Amos, I did that and it works fine. Thanks. Best regards, Migrate -- 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 -~----------~----~----~----~------~----~------~--~---