Forum: Ruby on Rails Validate field not in model?

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.
Af25c598c54850cd55e07b1d060df9e1?d=identicon&s=25 Mike Chai (mlchai)
on 2009-02-27 03:51
(Received via mailing list)
I want to validate a field in my form that's not an attribute in the
model. How do I do this?
A1b97dafea62b11e7b3bef338ce3fe83?d=identicon&s=25 Billy Hsu (cfc)
on 2009-02-27 06:53
(Received via mailing list)
define it as a getter and setter.

On Fri, Feb 27, 2009 at 10:49 AM, Mike C <snibble@gmail.com> wrote:

>
> I want to validate a field in my form that's not an attribute in the
> model. How do I do this?
> >
>


--
TWRUG Blog:
http://blog.rubyonrails.org.tw

CFC on Rails:
http://zusocfc.blogspot.com

Only two surfaces of a box:
http://blog.pixnet.net/zusocfc
Af25c598c54850cd55e07b1d060df9e1?d=identicon&s=25 Mike Chai (mlchai)
on 2009-02-27 07:11
(Received via mailing list)
Ok, I did it. But in the model I have validates_presence_of, and even
though the field is filled, I keep getting the blank error.
Af25c598c54850cd55e07b1d060df9e1?d=identicon&s=25 Mike Chai (mlchai)
on 2009-02-27 09:20
(Received via mailing list)
Nevermind, getter was returning a user object instead of a string.
fixed. :)
D921e53e9ad4d762fd022f45cdd63da0?d=identicon&s=25 Nilesh Kumar (nilez)
on 2009-02-27 10:03
(Received via mailing list)
Hi Mike. Can you share the code snippet for the getter and setter
methods
you used,  thanks.
This topic is locked and can not be replied to.