Forum: Ruby on Rails Validation inside controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D3760253015655d7441a4206c762934d?d=identicon&s=25 Migrate (Guest)
on 2007-06-08 10:08
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
F04aeb28129f653b207e8b5d92706096?d=identicon&s=25 Amos King (Guest)
on 2007-06-08 19:51
(Received via mailing list)
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@andreas-s.net> wrote:
>
>
--
Amos King
A. King Software Development and Consulting, L.C.
http://dirtyInformation.com
--
Looking for something to do? Visit http://ImThere.com
8608f2d7f02c6d0f1c349b7b94b1cea5?d=identicon&s=25 liquidautumn (Guest)
on 2007-06-08 20:01
(Received via mailing list)
> because I allow the user to add new columns to a model
in 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?
D3760253015655d7441a4206c762934d?d=identicon&s=25 Migrate (Guest)
on 2007-06-08 21:11
Hello Amos,

I did that and it works fine.

Thanks.
Best regards,
Migrate
This topic is locked and can not be replied to.