0
私はモデルActesとモデルを持っています。お互いの関係でhabtmです。強力なパラメータを使ってネストされた属性を取得する
新しいアクテフォームをサーバーに送信すると、強力なパラメータを取得できません。
これはparams[:acte]
である:
"acte"=>{
"biblio_id"=>"1",
"acte_numero"=>"12",
"keywords_attributes"=>{"0"=>{"keyword"=>"attestation, "}},
"texte"=>"<p>test</p>",
"complement"=>""
}
モデルacte.rbは含まれています
has_and_belongs_to_many :keywords
belongs_to :user, optional: true
belongs_to :biblio, optional: true
belongs_to :archive, optional: true
has_many :comments
accepts_nested_attributes_for :keywords, allow_destroy: true,
注:私はaccepts_nested_attributes_for
にreject_if: :all_blank
を追加した場合、フォームはまったく送信されません。
これはacte_controllerである:
def params_acte
params.require(:acte).permit(:biblio_id,
:acte_numero,
:keywords_attributes =>[:keyword],
: resume,
# cut for brievity
これは、あなたが最後にkeywords_attributes
を追加する必要がありますsyntax error, unexpected ',', expecting => :resume, ^