# Form\_for and virtual attribute

**URL:** <https://www.ruby-forum.com/t/form-for-and-virtual-attribute/108640>\
**Category:** Rails\
**Created:** [July 5, 2007, 3:40pm UTC](https://www.ruby-forum.com/t/form-for-and-virtual-attribute/108640 "2007-07-05T15:40:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [July 5, 2007, 3:40pm UTC](https://www.ruby-forum.com/t/form-for-and-virtual-attribute/108640/1 "2007-07-05T15:40:10Z")

</div>

I have an ‘edit\_user’ template that looks like this:

```
<% form_for :user, @user, :url => { :action => 'edit_user' } do |f|

```

%\>

User Name:  
\<%= f.text\_field :name %\>

Full Name:  
\<%= f.text\_field :fullname %\>

  

Password:  
\<%= f.text\_field :password %\>

  

Confirm:  
\<%= f.text\_field :password\_confirmation %\>

  

User Role:  
\<%= select\_tag “user[role]”, @options %\>

```
    <%= submit_tag "Save Changes", :class => "submit" %>
<% end %>

```

The problem is that it never displays existing data for the password and  
password\_confirmation attributes. Password is a virtual attribute that  
actually points to a hashed\_password in the db, as shown in the AWDWR  
book.

This makes things difficult, because if I want to edit a user, I have to  
know their existing password.

How do I get a virtual attribute to place it’s value in the above  
:password and :password\_confirmation boxes?

Thanks!
