Guest User

Untitled

a guest
Jun 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Person
  2. include Mongoid::Document
  3. field :name
  4. references_many :preferences, :stored_as => :array, :inverse_of => :people
  5. end
  6.  
  7. class Preference
  8. include Mongoid::Document
  9. field :name
  10. references_many :people, :stored_as => :array, :inverse_of => :preferences
  11. end
  12.  
  13. ps1 = Person.create(:name => 'John Doe')
  14. pf1 = Preference.create(:name => 'Preference A')
  15.  
  16. ps1.preferences << pf1
  17. ps1.preferences << pf1
Add Comment
Please, Sign In to add comment