Skip to content

Instantly share code, notes, and snippets.

@apolzon
Created January 2, 2011 07:50
Show Gist options
  • Select an option

  • Save apolzon/762390 to your computer and use it in GitHub Desktop.

Select an option

Save apolzon/762390 to your computer and use it in GitHub Desktop.
class User
include Mongoid::Document
references_many :sombreros, :inverse_of => :wearer, :class_name => "Hat"
end
class Hat
references_in :wearer, :inverse_of => :sombreros, :class_name => "User", :stored_as => :array
end
User.sombreros uses a Mongoid::Criterio with an @selector querying the user_id. It should query for the wearer_id.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment