2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails で金額、小数点、Decimal を扱う

Posted at

小数点の問題

消費税計算でありがちな浮動小数点問題
http://easyramble.com/rails-migration-with-decimal.html

BigDecimal の指定

Railsマイグレーションでdecimal型の精度(桁数)を指定
http://easyramble.com/rails-migration-with-decimal.html

通貨型

Postgresqlのデータ型一覧とRailsのマイグレーションの指定方法
http://ruby-rails.hatenadiary.com/entry/20150607/1433606267
通貨型良さそうだが、、pg向けか。

Migration

Rails API PostgreSQL money
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/PostgreSQL/ColumnMethods.html#method-i-money
pg依存?

Gem

Money Rails
https://github.com/RubyMoney/money-rails
ちょっと複雑か気がする。。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?