Created
June 22, 2009 02:54
-
-
Save ashgti/133782 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Project | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :title, String, :nullable => false | |
| has 2..n, :tasks | |
| def create_or_update | |
| transaction do |tnx| | |
| raise "error with project" unless save | |
| tasks.each do |t| | |
| raise "Error with tasks" unless t.save | |
| end | |
| end | |
| end | |
| end | |
| class Task | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :project_id, Integer, :key => true | |
| property :title, String, :nullable => false | |
| belongs_to :project | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment