Skip to content

Instantly share code, notes, and snippets.

@krishna-shilpakar
Created December 2, 2010 05:59
Show Gist options
  • Save krishna-shilpakar/724847 to your computer and use it in GitHub Desktop.
Save krishna-shilpakar/724847 to your computer and use it in GitHub Desktop.
example_model
class Person
include Mongoid::Document
field :name, :type => String
field :age, :type => Integer
field :address, :type => Hash
end
/***** ADDING THROUGH CONSOLE ******/
p = Person.create(:name => 'John warden', :age => 30, :address => {:city => 'city, :street => 'street'}) // this will create a record in DB
/****** USING PICKLE *********/
Given a person exist with name: "John warden", age: 30, address: {:city => 'city', :street => 'street'}
// It doesn't find any pickle steps rather it say no step defined.
Note: address is not embedded or referenced document, It is a field in a person with type Hash. I do know we could embed address, so it only the example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment