Skip to content

Instantly share code, notes, and snippets.

@datenimperator
Created April 28, 2014 16:09
Show Gist options
  • Save datenimperator/11376548 to your computer and use it in GitHub Desktop.
Save datenimperator/11376548 to your computer and use it in GitHub Desktop.
Unique numbering DSL
class Model < ActiveRecord::Base
# setzt :invoice_id Attribut im before_create
has_unique :invoice_id,
scoped_by: lambda{ Time.new.year },
formatter: lambda{ |scope, value| sprintf("R-%04d-%04d", scope, value) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment