Forum: Ruby on Rails Validating a non-object attribute in a form via checkbox?

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.
320b651f98fa44b807d99bd7f4aac40d?d=identicon&s=25 Richard Sandilands (Guest)
on 2006-06-12 06:18
(Received via mailing list)
Hi there

A user can place an ad with various attributes via a form; however, I
want the user to check a box signifying that they've read the terms
and conditions for use of the site.

So the 'terms'  is not an attribute of the Advertisement model. I
could check that the user has ticked the box in my controller but
would like to bundle this up with the validation process.

How to ensure that the checkbox is ticked before the ad object is
saved as part of the model validation?

Any clues appreciated

Richard Sandilands
58c6efb8466b9f85155fe6aa9fc37fce?d=identicon&s=25 Chris T (Guest)
on 2006-06-12 09:20
(Received via mailing list)
Should the terms perhaps be part of the user model -- it could then be
part of the user validation (using *validates_acceptance_of)*?
320b651f98fa44b807d99bd7f4aac40d?d=identicon&s=25 Richard Sandilands (Guest)
on 2006-06-14 01:06
(Received via mailing list)
Ah, validates_acceptance_of !!
 That works fine and is exactly what I was after.

many thanks

Richard
This topic is locked and can not be replied to.