0

这是我的主要改革表格对象;

class CardHolderSupplierForm < ApplicationForm
  property :supplier_id, validates: { presence: true }
  property :standing_order, form: StandingOrderForm
end

而 StandingOrderForm 是;

class StandingOrderForm < ApplicationForm
  property :amount_pence
  property :reference
  property :frequency
end

我在standing_orders 中有一个名为的列,该列amount_currency应始终为“GBP”。我似乎无法让改革为我推这个。我尝试了各种方法;

class StandingOrderForm < ApplicationForm
  property :amount_pence
  property :reference
  property :frequency

  # does nothing
  def amount_currency
    "GBP"
  end

  # does nothing - can't even binding.pry
  def save
    model.amount_currency = "GBP"
    super
  end

我不知道如何让这个工作。表格的其余部分正常工作。

4

1 回答 1

1

使用改革的默认值设置怎么样?

property :amount_currency, default: "GBP"
于 2016-09-19T12:49:24.617 回答