This project is archived and is in readonly mode.

#3374 ✓committed
Dennis Theisen

text_field() does not use overridden model accessors

Reported by Dennis Theisen | October 14th, 2009 @ 02:23 AM | in 3.0.2

The following is an old problem, which still hasn't been fixed.

I couldn't find the same issue on Lighthouse, so I submitted the ticket again. If you this is a duplicate please feel free to delete it, but I can confirm the problem still exists in 2.3.4 and it feels like it should be fixed! (there is even a patch already)

This was the original ticket on Trac: http://dev.rubyonrails.org/ticket/3519

When utilizing text_field, the value of the text field when the form is populated from the database is not being pulled from the overridden Model accessor, but is instead being directly pulled from the Model. Example:

In the View: <%= text_field( 'db', 'name' ) %>

In the Model:

def name
  # Return the name of the db, less the prepend of 'sitename_' name = read_attribute(:name) site = self.site return name = name.gsub(site.name + "_",)
end

This overridden method works great when calling db.name.

Expected result: text_field uses overridden method like everyone else. Actual result: text_field just grabs the direct data.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages