Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created June 22, 2009 02:54
Show Gist options
  • Select an option

  • Save ashgti/133782 to your computer and use it in GitHub Desktop.

Select an option

Save ashgti/133782 to your computer and use it in GitHub Desktop.
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