Forum: Ruby on Rails form_for and virtual attribute

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jason F. (Guest)
on 2007-07-05 17:40
I have an 'edit_user' template that looks like this:

    <% form_for :user, @user, :url => { :action => 'edit_user' } do |f|
            <label for="user_name">User Name:</label>
            <%= f.text_field :name %>
            <label for="user_fullname">Full Name:</label>
            <%= f.text_field :fullname %>
            <label for="user_password">Password:</label>
            <%= f.text_field :password %>
            <label for="user_password_confirmation">Confirm:</label>
            <%= f.text_field :password_confirmation %>
            <label for="user_role">User Role:</label>
            <%= 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

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?

This topic is locked and can not be replied to.