Skip to content

Instantly share code, notes, and snippets.

View skylar's full-sized avatar

Skylar Woodward skylar

  • New York, NY
  • 01:18 (UTC -04:00)
  • X @skylar
View GitHub Profile
@burningTyger
burningTyger / README.md
Created December 27, 2011 15:16
Mongomapper many to many associations with variable key names

If you're not familiar with Rails and ActiveRecord in general or with ActiveModel in particular then MongoMapper can be difficult to cope with at times. Even though the docs are fine and in detail some parts seem to be missing that are probably obvious for those coming from Rails. I'm not a Rails guy so I post my experience with many to many associations that might help one or the other save some precious debugging hours.

Take this code:

class User
  include MongoMapper::Document
  key :name, String, :required => true
  key :email, String

key :post_ids, Array