Forum: Ruby on Rails Valitation only on one page?

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.
Bryan C. (Guest)
on 2006-03-21 18:11
Hello there,

I have a "user" object essentially that contains address information
that gets stored in the database. The user can sign up and go through
the whole page before he needs to enter that information which is
associated with a billing process. Without having to write some odd
validation based on the request_uri and passing it to a custom
validation method is there any way I can make the validates_presence_of
only occur on the one billing action, and no where else such as account
creation or account updates? Thanks ahead of time.
Xavier N. (Guest)
on 2006-03-21 18:28
(Received via mailing list)
On Mar 21, 2006, at 17:11, Bryan C. wrote:

> account
> creation or account updates? Thanks ahead of time.

Just off the top of my head looks like a user does not require a
billing address, and your model correctly reflects that.

The billing address is a model in its own and it is required for the
*bill*. So I'd move that validates_presence_of to the Bill model. On
the other hand the billing address belongs_to a user that has_one
billing address. Then, it is the billing address who
validates_presence_of :user. That matches your current flow.

Just some quick feedback that may be nonsense in the real application.

-- fxn
This topic is locked and can not be replied to.