Plugins - acts_as_currency
Add to favoritesThere's a problem in ActiveRecord. Let's say you have a field in a table that's supposed to be money, for example:
add_column :products, :price, :decimal
and you have an entry form on your website for admins to add products. Without even thinking, they will likely type the price with a dollar sign ('$'). If you follow the principal of least surprise, you will need to support this scenario. However, since ActiveRecord interprets the type as a decimal (since that's how it is in the database), you will get a silent fail in which all of your prices are 0! This is because all characters after the first non-number are interpreted as 0. That's where acts_as_currency comes in. Add it to your model and pass in any price fields, and they will all be able to take a '$'. Hope you enjoy! If you have any questions, please feel free to contact me at joe@faithfulgeek.org.
http://www.faithfulgeek.org/2008/3/26/acts_as_currency-released
git://github.com/faithfulgeek/acts_as_currency.git
Rails' (MIT)
Assets
