I’ve been trying to use a facade column but I notice that the form
helpers don’t seem to respect the facade.
In the following example I’m trying to story the prices as Integer
values but present them to the user as decimals.
class Product < ActiveRecord::Base
and for the most part that works great, I can call product.price and
9.99, I call product.price=9.99 and it gets stored in the DB as 999.
However, when I use the form helpers in the views…
<%= text_field ‘product’, ‘price’ %>
I get a text field with the value 999. I assume this is because the
form helpers are calling for the attributes in a more direct fashion.
Either with read_attribute or directly accessing @attributes.
My question is: is this a bug with the form helpers (or is there a
reason they use lower level code), have I made a mistake in my code, or
have I just approached the problem in the wrong way? I think probably
one of the latter two.
Many thanks for your time.