Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoid equivalent of ActiveRecord's `serialize` method

hope the title's pretty self-explanatory.

I'm using mongoid as my ORM for a Rails app, and I was wondering if anybody knew if it has an equivalent to ActiveRecord's serialize method. I've looked through the mongoid documentation but haven't been able to find anything yet.

Here's an example of the model:

class Foo
  include Mongoid::Document

  field :params, type: String
  serialize :params            # method from ActiveRecord
end

Thanks in advance!

like image 662
mportiz08 Avatar asked Aug 18 '11 19:08

mportiz08


1 Answers

You don't need to serialize with MongoDB as far as you can store in fields Arrays and Hashes.

field :hash_params, type: Hash
field :array_params, type: Array
like image 154
fl00r Avatar answered Nov 11 '22 04:11

fl00r