我正在使用嵌套表单,我想使用number_with_precision
. 但是,我在理解如何挂钩该值时遇到问题。它在父窗体中工作。如下所示,我尝试使用thing
对象本身(我认为这是正确的方法)。我哪里错了?
= bootstrap_nested_form_for @quote, label_errors: true, label_col: "col-sm-2", control_col: "col-sm-6" do |f|
=f.text_field :primary_fee, value: (@quote.primary_fee > 0 ? number_with_precision(@quote.primary_fee, precision: 2) : "20.00"), prepend: "<i class='fa fa-dollar'></i>".html_safe, control_col: "col-md-6"
= f.fields_for :things, :wrapper => false, label_errors: true, html: {class: 'form_inline'} do |thing|
= thing.text_field :price, value: number_with_precision(thing.price, precision: 2), prepend: "<i class='fa fa-dollar'></i>".html_safe, label: "Cost", class: "input-sm"