Skip to content

Instantly share code, notes, and snippets.

@zhhz
Created June 24, 2009 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhhz/135293 to your computer and use it in GitHub Desktop.
Save zhhz/135293 to your computer and use it in GitHub Desktop.
# dm modle
class SampleOrder
include DataMapper::Resource
property :id, Serial
property :order_no, String
...
before :save, :set_order_no
def set_order_no
attribute_set(:order_no, next_order_no) if order_no.nil? || order_no.blank?
end
private
def next_order_no
...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment