Created
April 28, 2014 16:09
-
-
Save datenimperator/11376548 to your computer and use it in GitHub Desktop.
Unique numbering DSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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