Forum: Ruby on Rails validation only on a specific action

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 Hugo (Guest)
on 2006-02-03 21:55
Hello again!

I have a action that lists users and that allows an admin user to create
new users. When the admin user creates a new user an e-mail is sent to
the created user telling him to register in the site. I want to validate
the user name and password only when the user register and not when the
admin user creates it. Can anyone tell me how to do this?

Thanks.

Best regards,
Hugo
480cd6d5c2d7ff8d7f83a67137eb794d?d=identicon&s=25 Zack Chandler (Guest)
on 2006-02-03 22:11
(Received via mailing list)
Hugo,

Use validate_on_create() and validate_on_update() to implement the
validations you want done at the appropriate times.

or

Create 2 db tables: invites and users and script/generate corresponding
models and controllers.  This complicates things a bit but will keep
your
users table cleaner if you expect a lot of unanswered invites.

Hope this helps,
Zack
D3760253015655d7441a4206c762934d?d=identicon&s=25 Hugo (Guest)
on 2006-02-05 20:09
Hello Zack.

Thanks for the help.
I'm considering using the second approach you talked about because I
want to validate also the admin user.

Bye,
Hugo

Zack Chandler wrote:
> Hugo,
>
> Use validate_on_create() and validate_on_update() to implement the
> validations you want done at the appropriate times.
>
> or
>
> Create 2 db tables: invites and users and script/generate corresponding
> models and controllers.  This complicates things a bit but will keep
> your
> users table cleaner if you expect a lot of unanswered invites.
>
> Hope this helps,
> Zack
This topic is locked and can not be replied to.