Serialized Hash field and Simple Form

后端 未结 4 1129
不思量自难忘°
不思量自难忘° 2020-12-09 19:39

I have the following.

class Page < ActiveRecord::Base
  belongs_to :category
  serialize :fields
end

The value of fields wi

4条回答
  •  萌比男神i
    2020-12-09 20:37

    If only I´ve found this post earlier I would not have missed three days on this issue.

    I was not able to comment on the answear so just to add, if anyone trying to fields_for a mongo array of hashes (has_many like) additionally you will need to supply the root OpenStruct object with a "#{key}_attributes=" (in this case fields_attributes=) method so fields_for would identify it is a has_many relation.

    Hope it helps someone ;)

提交回复
热议问题