All pastes #941602 Raw Edit

Unnamed

public ruby v1 · immutable
·published 2008-03-13 20:29 UTC
rendered paste body
class Todo < DataMapper::Base  property :todo, :text  property :status, :string  property :done, :boolean  belongs_to :context  belongs_to :category  def to_s    "#{status} #{todo} <#{context}> [#{category}] -- #{done.to_s}"  endendTodo.table.create! unless Todo.table.exists?class Category < DataMapper::Base  property :name, :string  has_many :todosendCategory.table.create! unless Category.table.exists?class Context < DataMapper::Base  property :name, :string  has_many :todosend# je crée mon model comme ceci: (todo est un hash que j'obtiens par une methode que je n'ai pas indiquer ici)t = Todo.new({:status => todo[:status], :todo => todo[:todo], :done => false})context = t.context.create :name => todo[:context]category = t.category.create :name => todo[:category]t.save