Skip to content

Instantly share code, notes, and snippets.

@pacifists
Created August 25, 2010 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacifists/548876 to your computer and use it in GitHub Desktop.
Save pacifists/548876 to your computer and use it in GitHub Desktop.
class Project
include Mongoid::Document
include Mongoid::Timestamps
....
embeds_many :expenses
....
end
class Expense
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
field :amount, :type => Integer
field :description
field :expense_type, :type => Integer
field :expense_date, :type => Date
field :users_name
field :tags, :type => Array
field :user_id
index :tags
index :user_id
index(
[
[:expense_date, Mongo::DESCENDING],
[:created_at, Mongo::DESCENDING]
])
embedded_in :project, :inverse_of => :expenses
....
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment