Ruby on Rails - Rails Admin和Money Gem

时间:2017-06-08 04:51:28

标签: ruby ruby-on-rails-5 rails-admin

好吧所以我试图在我的payment.rb模型中使用以下代码来使用Money gem将货币值转换为美分以便于存储。问题是我无法弄清楚如何告诉Rails管理员将这个用于这些字段。我没有找到很多关于Rails管理员如何处理钱的事实,事实上我还没有找到一个关于在Rails Admin中处理钱的参考。 必须有一种方法可以做到这一点,如果有人能指出我正确的方向,这将是伟大的。哦,我正在跑步

  composed_of :fee,
              :class_name => 'Money',
              :mapping => %w(price, cents),
              :converter => Proc.new { |value| Money.new(value) }

  composed_of :other_fee,
              :class_name => 'Money',
              :mapping => %w(price, cents),
              :converter => Proc.new { |value| Money.new(value) }

  composed_of :total,
              :class_name => 'Money',
              :mapping => %w(price, cents),
              :converter => Proc.new { |value| Money.new(value) }

  composed_of :payment_amount,
              :class_name => 'Money',
              :mapping => %w(price, cents),
              :converter => Proc.new { |value| Money.new(value) }

0 个答案:

没有答案