Skip to content

Instantly share code, notes, and snippets.

@HeroicEric
Created October 27, 2011 14:44
Show Gist options
  • Select an option

  • Save HeroicEric/1319737 to your computer and use it in GitHub Desktop.

Select an option

Save HeroicEric/1319737 to your computer and use it in GitHub Desktop.
class Product
include DataMapper::Resource
property :id, Serial
property :title, String, :required => true
property :description, Text, :required => true
has n, :variants
after :create, :make_master_variant
def make_master_variant
self.variants.create(:sku => "cf-19")
end
def html_description
Redcarpet.new(description).to_html
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment