에 대한 permit_params을 설정하는 방법이 내 모델은 다음과 같습니다다른 모델
Product.rb :
class Product < ApplicationRecord
belongs_to :position
has_many :products_sizes
has_many :sizes, through: :products_sizes
has_many :reviews, dependent: :destroy
accepts_nested_attributes_for :products_sizes
end
Products_size.rb :
class ProductsSize < ApplicationRecord
belongs_to :product
belongs_to :size
has_many :prices
accepts_nested_attributes_for :prices
end
Size.rb :
class Size < ApplicationRecord
has_many :products_sizes
has_many :products, through: :products_sizes
end
및 Price.rb :
class Price < ApplicationRecord
belongs_to :products_size
end
나는 제품을 업데이트 할 때 내가이 제품에 대한 양식을 만들 필요가 ActiveAdmin을에서
, 내가 양식 외모 때문에 일부 가격을 만들 수를 like :
... #here is the begining of the form
f.inputs 'Sizes' do
f.semantic_fields_for ProductsSize.where(product_id: params[:id], size_id: Product.find(params[:id]).products_sizes.size.to_i).first.prices.new do |ps|
ps.input :products_size_id, label: 'Size', as: :select, collection: Product.find(params[:id]).sizes.map { |s| ["#{s.title}", s.id] }
ps.input :quantity
ps.input :amount
li do
link_to 'Add size', '#'
end
end
end
제출 버튼을 클릭 할 때를 제외하고는 모두 가격이 생성되지 않습니다. 제 생각에는 price
에 대해 permit_params
이 지정되어 있지 않기 때문입니다. 어떻게 지정할 수 있습니까? 감사. 여기
예,하지만'permit_params'는 내 'Product' 모델이 아니라'belongs_to : products_size' 관계가있는'Price'를 설정해야합니다. 나는 ProductsSize 모델을 통해'Price'에 도달한다. –
컨트롤러에서 매개 변수를 허용 했습니까? –