I have a form which permits updating of a user record. It contains fields for :password and :password_confirmation but I do not want validation to run on them if an encrypted password is already stored in the database.
The fields from the view file:
<%= f.password_field :password %>
<%= f.password_field :password_confirmation, :label => 'Confirm Password' %>
In searching the internet, I found this bit of code, which I assume was for a previous version of Ruby/Rails. (Which I would place in my user model.)
validates_presence_of :password, :on => create
As the syntax for my password validation in my user model is different (below), I'm confused about the syntax I would need.
validates :password, :presence => true, :confirmation => true
I have searched other posts and sure could use some direction.
-- Disclaimer -- I did see that there is a screen cast about conditional validations but I'm not able to watch it at the moment.
Thanks, all.
Edit - inserted the following code and it does permit a user record update without complaining about the password field missing.
validates :password, :presence => true, :confirmation => true, :on => :create