For my users model, the password field cannot be the same as the
username, which is checked by the validate method in the model:
class User < ActiveRecord::Base ... def validate if password == username errors.add(:password, "Cannot be the username") end end end
This works fine when creating a new user. However it fails when a
user wants to change their password.
The reason it fails is that the update/edit form view does not let
the user change their username (usernames are static). So when the
validate method (above) is ran it does not know what the username is.
What is the rails-way for tackling this?