Handling Decimal Precision in Rails - DEV Community

10-Jun-2023 2978
Ruby on Rails allows us to specify how precise we want decimals to be by defining precision and scale in database migrations. Rails also provides a way of adding front-end validation to forms that accept decimal values. I’ll be using an expense model that lets a user track expense amounts as an example. I’ll also point out differences between SQLite and PostgreSQL in regards to saving decimals beyond constraints.

Free eBook download

Download all our eBooks for free from Gumroad!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these books offer thousands of essential questions and answers across multiple languages. Download the complete collection for free from our Gumroad page. Free Ultimate Job Interview Preparation eBook collection