verschachtelte Attribute für has_one association

Ich brauche, um das setup Parametern für die hat ein Verein in den neuen und Aktionen Bearbeiten, so habe ich diese:

Produkt-Modell

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

controller

params.require (: - Shop).Genehmigung (: - Shop).Genehmigung!

Felder angezeigt, aber wenn ich Absenden, ist es nicht sinnvoll, store-Verband leer ist. Wie problem gelöst werden kann?

UPD

params.require(:product).permit(store_attributes: [:store_id, :supplier_id, :margin, :discount]).permit!

Protokolle:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"...", "product"=>{"name"=>"qwefqwefasdf", "description"=>"", "permalink"=>"asdf", "store_attributes"=>{"margin"=>"123", "discount"=>"123"}}, "button"=>"", "id"=>"asdf"}
InformationsquelleAutor Mark Pegasov | 2013-12-19
Schreibe einen Kommentar