password not a column in the database, is it? Attribute only?
So there is no password_changed? method password_changed? that would be available if password was a column. Rather, you just need to check if password at all.
Sort of:
validates :password_confirmation, :presence => true, :if => '!password.nil?'
Although this solves the initial problem you are facing, it still will not do what you want, as it only checks for availability, and you need it to be present and match the password. Something like the following should work (combined with the above check).
validates :password,
If you have not seen :confirmation before, this is a standard check that looks for foo and foo_confirmation and ensures that they are the same.
Please note that you still need to check for password_confirmation
source share