I want to make sure a combination of email and name are unique in a database for a newsletter signup application What would be the railsy-ish way to do it? here are a couple of ways I can think of accomplishing this o Extend validation o Make a unique primary key column in the database Clayton Cottingham WinterMarket Networks Phone: (604) 417-3254 Vancouver, B.C. Canada http://www.wintermarket.net MSN:drfrog666-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org AIM:drfrogrx --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m not sure if writing a validate method is considered "extending validation", but that''s the way I''d do it. And also a DB constraint; just in case. It protects the integrity of your data regardless of how it got there, since not all paths may be through your application. On 9/17/06, Clayton Cottingham <dr.frog-fVOoFLC7IWo@public.gmane.org> wrote:> > > > > I want to make sure a combination of email and name are unique in a database > for a newsletter signup application > > > > What would be the railsy-ish way to do it? > > > > here are a couple of ways I can think of accomplishing this > > > > o Extend validation > > o Make a unique primary key column in the database > > > > > > > > > > Clayton Cottingham > > WinterMarket Networks > Phone: (604) 417-3254 > Vancouver, B.C. Canada > http://www.wintermarket.net > MSN:drfrog666-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > AIM:drfrogrx > > > > > > > >-- When a man says he approves of something in principle, it means he hasn''t the slightest intention of putting it into practice. -- Bismarck --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Clayton Cottingham wrote the following on 17.09.2006 23:11 :> > I want to make sure a combination of email and name are unique in a > database for a newsletter signup application > > > > What would be the railsy-ish way to do it? >validates_uniqueness of :email, :scope => :name if you want to validate uniqueness of a triplet or more validates_uniqueness of :first_attr, :scope => [ :second_attr, :third_attr ... ] Lionel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---