Skip to content

Instantly share code, notes, and snippets.

@dlt
Created October 7, 2010 12:56
Show Gist options
  • Save dlt/615063 to your computer and use it in GitHub Desktop.
Save dlt/615063 to your computer and use it in GitHub Desktop.
class Product
include Mongoid::Document
referenced_in :group
end
class Group
include Mongoid::Document
references_many :products, :stored_as => :array, :inverse_of => :group
end
group = Group.first
product = group.products.last
group.products.size # => 5
group.products.delete(product)
group.save
group.products.size # => 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment