ActiveRecord::AssociationTypeMismatch when attempting to save nested attributes in Rails

后端 未结 3 543
清歌不尽
清歌不尽 2021-01-13 20:58

I read through a lot of pages on `has_one relationships and nested attributes but haven\'t been successful in making this work. Any help would be fantastic.

Each Use

相关标签:
3条回答
  • 2021-01-13 21:03

    Not certain, think you need:

    <%= f.fields_for @network, :network_attributes do |fn| %>
    
    0 讨论(0)
  • 2021-01-13 21:15

    Incase someone else is having the same issue, I resolved this by changing:

    <%= f.fields_for @network do |fn| %> to <%= f.fields_for :network do |fn| %> and removing :network as an accessible attribute from the user model.

    0 讨论(0)
  • 2021-01-13 21:25

    If you remove :network from the model as an accessible it will not work for sure

    0 讨论(0)
提交回复
热议问题