I'm in need to setup attributes for has one association in new and edit actions, so I have this:
Product model
has_one :store
accepts_nested_attributes_for :store
form
= form_tag @product do |f|
= f.fields_for :store do |store_fields|
= render 'store_form', :f => store_fields
in controller
params.require(:store).permit(:store).permit!
fields displays, but when I'm submitting form, it doesn't make sense, store association is empty. How problem can be solved?
UPD
params.require(:product).permit(store_attributes: [:store_id, :supplier_id, :margin, :discount]).permit!
Logs:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"...", "product"=>{"name"=>"qwefqwefasdf", "description"=>"", "permalink"=>"asdf", "store_attributes"=>{"margin"=>"123", "discount"=>"123"}}, "button"=>"", "id"=>"asdf"}