Skip to content

Instantly share code, notes, and snippets.

@hakunin
Created December 25, 2009 15:55
Show Gist options
  • Select an option

  • Save hakunin/263659 to your computer and use it in GitHub Desktop.

Select an option

Save hakunin/263659 to your computer and use it in GitHub Desktop.
Few things to keep in mind when starting with Datamapper.
1. new records cannot be user in hashes
h = { Record.new => 1, Record.new => 2}
h.values # [2]
2. dm has associations
Don't try to rewrite their getters or setters.
No, attributes_set does not help.
3. want a Hash as a property?
Just forget about it.
4. dm doesn't save your record?
Method record.save returns true/false, exceptions? You wish!
Associations have default validations, add :required => false to them
Those took me plenty hours to find out about, I hope you don't have to share my experience.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment