On Mon, Aug 15, 2011 at 12:57 PM, tom <[email protected]> wrote:

> class Invoice < ActiveRecord::Base
> before_create :setuniqueno
> validates_uniqueness_of :uniquenumber
> def setuniqueno
>        self.uniquenumber = Time.now.to_i
> end
> end

> after the user post to the create function i also create an Invoice.
> what is not 100% clear to me, is what happens/how should i handle the
> case if the uniquenumber is not unique? eg if multiple user generate
> the same Timestamp

It's not clear what you're trying to do here. Each invoice will have a
unique ID by default;  what's this additional "unique number" for??

-- 
Hassan Schroeder ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to