0
多対多結合テーブルでカスタムフィールドを設定する必要があります。今はチェックボックスとの関係しか設定できませんが、数量フィールドも設定する必要があります。結合テーブルのFormtasticカスタムフィールド
マイモデル:
class Quote < ApplicationRecord
has_and_belongs_to_many :options, :join_table => :quotes_options
accepts_nested_attributes_for :options, :allow_destroy => true
end
class Option < ApplicationRecord
has_and_belongs_to_many :quotes
end
とフォーム:
form do |form|
form.inputs do
form.input :options, :as => :check_boxes,:collection => Option.all
end
end
だから今
それは
New Quote
[X] First option
[ ] Second option
質問のように、チェックボックスのリストとして表示され、その「表にあります。join_table =>:quotes_options "私もフィールド"を持っています:数量 " eも更新します。だから、私の見解は次のようになり、私は関節の表に数量を保存することができます
New Quote
[X] First option [ ] quantity
[ ] Second option [ ] quantity