Dynamic attributes with Rails and Mongoid

后端 未结 4 845
自闭症患者
自闭症患者 2020-12-13 07:28

I\'m learning MongoDB through the Mongoid Ruby gem with Rails (Rails 3 beta 3), and I\'m trying to come up with a way to create dynamic attributes on a model based on fields

4条回答
  •  [愿得一人]
    2020-12-13 08:05

    Be sure to set allow_dynamic_fields: true in mongoid.yml. Example:

    defaults: &defaults
      allow_dynamic_fields: true
      parameterize_keys: true
      persist_in_safe_mode: true
      raise_not_found_error: true
      reconnect_time: 3
      use_object_ids: false
    
    development:
      <<: *defaults
    
    ...
    

提交回复
热议问题