What do you think is the best way to handle money in rails?
At the moment i use a decimal field with a precision if 16 and a scale of 2.
the problem is that we use the comma as a decimal sign and this sometimes becomes a problem.
should i use the money gem or use only cents or do you guys have a better way to handle this?
Oh that's a really interesting question. I've never really considered that because we only use it in the other notation.
I would imagine that the Money gem can do the conversion for you and that internally it really saves them as decimals but tweaks the string output so that it uses comma for the decimal. I think you would want to continue saving with the decimal format and then have a method that converts the value into a Money object and that would be what you interact with. You could also probably have a setter method that lets you set the value via the comma version of the string which converts to the decimal one in the database.
Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.