Geekyra
2009-Feb-18 08:28 UTC
Validate uniqueness of category model depending on user model
How to make unique validation on category model that is belong to user model and the unique validation must depend on user model so for example every user may have their own unique category name but two or more user may have a same category name but they can''t have a same category name twice. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
MaD
2009-Feb-18 08:33 UTC
Re: Validate uniqueness of category model depending on user model
could you give an example to explain that a little bit more? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Feb-18 08:38 UTC
Re: Validate uniqueness of category model depending on user model
On Feb 18, 8:28 am, Geekyra <gkr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How to make unique validation on category model that is belong to user > model and the unique validation must depend on user model so for > example every user may have their own unique category name but two or > more user may have a same category name but they can''t have a same > category name twice.Use the :scope option on validates_uniqueness_of ? Fred --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Geekyra
2009-Feb-19 08:23 UTC
Re: Validate uniqueness of category model depending on user model
For example : (note: change category into product for easier understanding) There are 2 user : "User 1" may have product name it "CAR", "HOUSE", "HOUSE@XXX" "User 2" may have product name it "CAR", "CAR 2", "HOUSE@YYY", "HOUSE", "WALLET" The point is every user may have a same product but they need to maintain a user uniqueness product so "User 1" can''t have a new product name "CAR" cos it''s already have it on the first row product. I will try to look forward for Frederick suggestion, see if using :scope solve the problem. Thanks for Frederick On Feb 18, 3:33 pm, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> could you give an example to explain that a little bit more?--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---