Serialized Hash field and Simple Form

后端 未结 4 1141
不思量自难忘°
不思量自难忘° 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条回答
  •  一个人的身影
    2020-12-09 20:21

    Use OpenStruct. It works like this:

    require 'ostruct'
    
    struct = OStruct.new("address" => "8 finance street, hong kong", "founded" => "1973")
    struct.address # => 8
    struct.founded # => "1973"
    

提交回复
热议问题