Validation only on a specific action

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

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

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 C. 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs