0

我在下面有这个方法:

  def formatted_from_net_per_day
    return unless object.price.available?
    formatted_price_for(object.price.from_price)
  end

例如,它输出:

#<Money fractional:78571 currency:GBP>

formatted_price_for方法如下,它剥离了美分。

  def formatted_price_for(price)
    formatted_price = h.money_without_cents_and_with_symbol(price)
    unit = I18n.t("space.pricings.pricing.day")

    format('%s/%s', formatted_price, unit)
  end

我不想剥夺美分,而是想把钱四舍五入并保留货币。所以使用上面的示例输出 -£785.71 -> £786

我怎样才能做到这一点?

4

0 回答 0