I am a complete Rails newbie and am trying to understand how I can
simply get the data from a password field in a form that is not mapped
to a field in the database.
The scenario is this. I have a User model that is mapped to a table
users with the following fields: username, email_address, password and
join_dt. Following pretty closely to the login section in the Agile Web
Development with Rails book, the model takes the username, email_address
and password (which is hashed before_create()) from the form found in
the add_user view. It also makes join_dt = Time.now() in the model.
There is an associated add_user action in the login_controller that
passes the params to User.new() when a new user is created.
My question is that I want the password to be verified and entered twice
to ensure the user types the correct password. To do this I thought of
adding a password_field(“validate_pass”,“pass”) to the form in the view.
All the other form helpers are mapped to the “user” object. (i.e.
text_field(“user”, “username”). I then wanted to add a validate method
in the User model to check that self.password == this validated
password. However, I am not sure how to access the POST parameter in the
Can someone please explain to me what I am doing wrong or even if this
type of validation should be done in the Model. I thought of adding this
validation in the login_controller in the add_user method as well.
However, I am a bit confused at how to access this params hash even in
Please help and don’t mind my newbish question if the solution is a bit