Hi, In the Agile book, it is told that by putting a :unique => true will dedup the row with ActiveRecord. But it''s not working out for me. Do I need edge rails for this? I simply want to dedup any join model associations, for instance: category_id | inventory_id 384 1 first entry 384 2 this would be ok. 384 1 this would not be ok Any help is appreciated. Thanks -- 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 -~----------~----~----~----~------~----~------~--~---
On 12/20/06, Dominic Son <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi, In the Agile book, it is told that by putting a :unique => true will > dedup the row with ActiveRecord. > > But it''s not working out for me. Do I need edge rails for this? > > I simply want to dedup any join model associations, for instance: > > category_id | inventory_id > 384 1 first entry > 384 2 this would be ok. > 384 1 this would not be ok > > Any help is appreciated. ThanksI''m not 100% on :unique => true but you should be able to put validation into your join model to prevent these kinds of issues. eg validates_uniqueness_of :category_id, :scope => :inventory_id might do the trick. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 12/19/06, Dominic Son <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, In the Agile book, it is told that by putting a :unique => true will > dedup the row with ActiveRecord. > > But it''s not working out for me. Do I need edge rails for this?Use :uniq => true (note the spelling which matches Ruby''s Array#uniq method) on 1.2 or later. jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---