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