search for: position_in_category_not_unique

Displaying 1 result from an estimated 1 matches for "position_in_category_not_unique".

2009 Sep 25
12
uniqueness validation perplexity
I want to write a validate routine to check to enforce that a position must be unique in a category. (In another category, it doesn''t have to and shouldn''t need to be unique.) I write this code which works happily for new items: def position_in_category_not_unique @items = Item.find( :all, :conditions => [ "category_id = ? AND position = ?", category_id, position ] ) if @items.size > 0 errors.add_to_base... If, however, I try to *update* an existing item, because it''s already in the database, it gives the error. Any sug...