AssociationTypeMismatch (Object expected, got HashWithIndifferentAccess) in Rails app

后端 未结 2 522
没有蜡笔的小新
没有蜡笔的小新 2021-02-10 23:31

I\'m getting a AssociationTypeMismatch Error and I\'m not sure where I\'m making a mistake. I\'m pretty new to Rails so I\'m guessing I\'m making some silly mistake. I\'ve check

相关标签:
2条回答
  • 2021-02-10 23:57

    Give a shot.

    In your User model, try to add :preference_attributes to your attr_accessible line.

    class User < ActiveRecord::Base
      attr_accessible :email, :full_name, :password, :password_confirmation, :preference_attributes
      .. # rest of your code goes here
    end
    
    0 讨论(0)
  • 2021-02-11 00:00

    it is:

    attr_accessible :preference_attributes
    

    and in your form:

    <%= f.fields_for :preference_attributes do |builder| %>
    ...
    
    0 讨论(0)
提交回复
热议问题