Can someone explain why form helpers appear to bypass any model methods
I override for fields that are bound to database fields? It would be
great if someone could tell me how to force the form field, etc to call
the method instead of looking at the database / attributes collection.
Let’s say I have a column called ‘price’ in my database table “books”
Let’s say I want price to always come back as a special format when I
query my model… So in my model, I do
def price
number_with_precision(self.attributes[:price])
end
In a view, @book.price comes back formatted correctly as expected.
However, <%=text_field “book”, “price” %> bypasses my method and gets
the unformatted price.
It just doesn’t seem consistent. I’m currenly playing around with a hack
to form_helper et all, but it’s kinda complicated and so I was looking
for an explanation or an easy workaround. (I know I can set the
precision in my db to accomplish this issue but this is just an
example.)
Thanks much to anyone willing to help.
Brian H.
Web D.
Learning & Technology Services
Schofield 3-B
University of Wisconsin-Eau Claire
715 836 3585
[email protected]
Brian H.
Web D.
Learning & Technology Services
Schofield 3-B
University of Wisconsin-Eau Claire
715 836 3585
[email protected]