I was working on a plugin to enhance ActiveRecord’s models so that it’s
easy to handle decimal numbers and store them as integers. I was
dynamically creating instance methods to output the formatted attribute
(145 becomes 14.5)
Now there is a problem with Rails forms (for example), as they access
the attributes with instance_variable_get.
So to intercept that call, should I use alias_method_chain?
Ok so I’ve dropped work on the plugin and used decimal in rails
migration to aset the column type accordingly.
But now, 130 appears as 130.0 , which is ugly and could lead people to
misinterpret the a price as $1300. Is there an easy way to get rid of
trailing zeros?