ネストされたフォームを使用しており、を使用して text_field をフォーマットしたいと考えてい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"