Validate_presence_of - not always needed

hey,
I do some validation in my user.rb file when a user signing up
validates_presence_of :password

now, when the user want to edit its account, I dont want that the
password is checked anymore - how can I do that?

I need the validation only in the signup process but not in the account
editing process?

pete

If you only want to validate when the record is first created, you can
add:

:on => :create

to your helper, like this:

validates_presence_of :password, :on => :create

On subsequent record updates that validation will not be called.

/afb

Pete C. wrote:

hey,
I do some validation in my user.rb file when a user signing up
validates_presence_of :password

now, when the user want to edit its account, I dont want that the
password is checked anymore - how can I do that?

I need the validation only in the signup process but not in the account
editing process?

pete

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