ruby on rails - Do not deserialize ActiveRecord YAML.load-ing -
given yaml content similar to:
--- :template: :project_change :property: !ruby/activerecord:property attributes: id: '99' name: lorem ipsum 1 dolorem - 101 status: available
how make sure there no queries db when deserialising content?
any activerecord
values can ignored, instead of being returned.
the (ugly) workaround found this:
yaml.load(yaml_content.gsub(/(!.+activerecord.+)/, ''))
which convert yaml above to:
--- :template: :project_change :property: attributes: id: '99' name: lorem ipsum 1 dolorem - 101 status: available
meaning activerecord entry becomes regular hash.
this ugly , if tell don't want activerecord
classes returned.
using ruby 1.9/2, rails 3.2, recent versions of other gems.
Comments
Post a Comment