Hi, Added STI and it''s messed with my validates_uniqueness. I was hoping a validate_uniqueness in the base class would validate a field regardless of the derived classes....but it seems not to be. Any ideas how I can enforce the below uniqueness across all inherited classes? validate_uniqueness_of :xyz_id , :scope => "user_id" Only thing I can think of is trying before_saves and before_updates somewhere and including them in each inherited class definition. Many Thanks Andy -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Andy Watts wrote:> Added STI and it''s messed with my validates_uniqueness. > I was hoping a validate_uniqueness in the base class would validate a > field regardless of the derived classes....but it seems not to be. > > Any ideas how I can enforce the below uniqueness across all inherited > classes? > validate_uniqueness_of :xyz_id , :scope => "user_id"This is an as yet unfixed problem with Active Record http://dev.rubyonrails.org/ticket/3833 http://dev.rubyonrails.org/ticket/5303 The quick fix I use is to change the following line 1.2.3: http://dev.rubyonrails.org/browser/tags/rel_1-2-3/activerecord/lib/active_record/validations.rb#L551 Trunk: http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/validations.rb#L613 removing "record.class", leaving a plain find. Mark -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
ThankYou! Will give this a go. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---