Validates_presence_of?

I have a situation in which I would like it to be possible to create a
user. But also allow an administrator to modify certain values
associated with that user (username, email, privileges). I have
created my own authentication system based on an example I found.

My problem is that currently I am validating the presence of all the
fields in the table (for new user creation). What would be the best
way to have it not worry about some fields (password and confirm for
example) when modifying? I don’t want the admin to have access to
user passwords.

Thanks,
Glen

I have a situation in which I would like it to be possible to create a
user. But also allow an administrator to modify certain values
associated with that user (username, email, privileges). I have
created my own authentication system based on an example I found.

My problem is that currently I am validating the presence of all the
fields in the table (for new user creation). What would be the best
way to have it not worry about some fields (password and confirm for
example) when modifying? I don’t want the admin to have access to
user passwords.

You can add “:on => :create” where :create can be :update as well… that
lets you “split” up your validations…

Thanks, actually I saw that in the api but it didn’t click with me.

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