Aldar
2006-Sep-11 20:32 UTC
validates_uniqueness_of :number by the year in a DateTime column
Hello all, I have a class Ticket < ActiveRecord::Base which has a property called :number and a property called :samples_date. a ticket number has to be unique over the same year. the year is given by the property called :samples_date I''m trying to validate the uniqueness of :number based on the year from the :samples_date property. i would like to specify the condition somehow in the :scope of the validates_uniqueness_of :number but i dont know how. Is there a way to restrict the validation of :number by the year from the samples_date column table? --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- validates_uniqueness_of doesn't work if value tested is numeric and column is string
- validates_uniqueness_of and create atomicity
- validates_uniqueness_of with a condition
- validates_uniqueness_of problem
- Dreamhost, fastcgi, validates_uniqueness_of.... is not always unique?