I started with LoginGenerator and have evolved a nice little ACL model
that is perfect for my app. The user model has statements like the
following in the model file that control validation of some of the login
fields:
validates_length_of :login, :within => 3…40
validates_length_of :password, :within => 5…40
validates_presence_of :login, :password, :password_confirmation, :on =>
:create
validates_uniqueness_of :login, :on => :create
validates_confirmation_of :password, :on => :create
My question is how do I get control when these fields fail with an
understanding of which validation clause failed?
My “new” view code runs and gets the fields for login then invokes
“create” in the controller. In the “create” method I am getting the
failure when I call the @user.save method to store the contents.
What I really want is to be able to tell the user what he screwed up and
return him to a partially filled out form in the “new” view so he can
fix the flawed fields. (user name too short, password confirm doesn’t
match, etc)
Thanks in advance.