Given a field in database defined as “discount_rate numeric(3,1)” I
found it not very usable for presenting it directly. For example, if
there’s a value 5.00 it will render in
<%= text_field ‘model’, 'discount_rate %>
as “0.5E1” which is not very friendly to user. All I do is that I write
kind of proxy accessors (prefixing with i_) for handling these
situations:
def i_discount_rate
sprintf(’%.2f’, discount_rate)
end
def i_discount_rate=(value)
self.discount_rate = value
end
Is there a better way for handling this? Having a bunch of input fields
makes the model fairly bigger in size.
–
Kamil