Modify an AR model attribute before reading into form_for

Hi,

I’m trying to modify an AR model’s foo attribute before reading into
the model’s edit form. I’ve tried the following:

class Model
def foo
"the foo attribute is " + read_attribute(:foo)
end
end

If I use a form_for on the edit view with the following code, I get
the plain database value inside the text field and the AR value next
to it:

<% form_for(@model) do |f| %>
<%= f.text_field, :foo %> <%= @model.foo %>
<% end %>

It seems like they should show the same value but they don’t. What am
I missing?

Thanks,
Harry

More on this topic. If I use a plain HTML input tag like so:

I get the correct value in the input box.

Does anyone know how FormBuilder gets its values? Is this a bug or is
it expected?

Harry