views:

16

answers:

2

Hi ,

My model User contains only field hashed_password but not password and confirmed_password, which are requested to provide when registering. How should I write the view in this case? Following code will generate error Model User does not respond to password.

17:   </div>
18:   <div class="field">
19:     <%= f.label :password %><br />
20:     <%= f.text_field :password %>
21:   </div>
+1  A: 

What you're looking for is called a virtual attribute. There's a good screencast on Railscasts that covers this: Railscasts - Virtual Attributes

Edit: In the case of your password and confirmed_password fields, you'll also want to look into filtering sensitive data from the request log as well using filter_parameter_logging.

andymism
A: 

But if it's fot authentication problem, you should probably use some sort of libs, like authlogic or devise, both these library would provide you with this virtual attributes.

tal