3nd3r
1
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
3nd3r
2
On 12/19/06, Dominic S. [email protected] 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
3nd3r
3
On 12/20/06, Dominic S. [email protected] wrote:
384 1 first entry
384 2 this would be ok.
384 1 this would not be ok
Any help is appreciated. Thanks
I’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.