Validate_format_of except=>?

Hi all,

I do a save on some user information in controller called my_controller.
In my model for User I have a validation for the password:

validates_format_of :password, :with => /^\w+$/, :message => ‘Password must be alphanumeric’, :on => :save

What I need to do, in this case, is to validate the save except for when
the save is called by this method in this controller. For example, I
would like to say:

validates_format_of :password, :with => /^\w+$/, :message => ‘Password must be alphanumeric’, :on => :save, except =>
[:submit]

However, the problem here is that :submit is the name for a method in
the controller and not the model where this validation is taking place.
And because I never pass the password along as a parameter, the
validation always fails. Is there a way to do this? Thanks,

-Shandy

On 9/12/07, Shandy N. [email protected] wrote:

the save is called by this method in this controller. For example, I
would like to say:

validates_format_of :password, :with => /^\w+$/, :message => ‘Password must be alphanumeric’, :on => :save, except =>
[:submit]

However, the problem here is that :submit is the name for a method in
the controller and not the model where this validation is taking place.
And because I never pass the password along as a parameter, the
validation always fails. Is there a way to do this? Thanks,

Don’t try to make the model behavior on a controller action name.

This problem has been solved by others. Study a plugin like
acts_as_authenticated to see how they do it.

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