I'm trying to validate the uniqueness of a value in a model where a
user has_one item. When the record is created, this isn't a problem
as I just use validate_uniqueness_of. However, on update, I need to
be able to bill the user the difference between their existing item
and their new amount:
class Item < CachedModel
validates_uniqueness_of :value, :message => "Somebody's already got
that spot. Nudge it by 1 and try again."
deduct_payment(self.value) if !bidup?
deduct_payment(self.bidup) if bidup?
self.value += self.bidup if bidup?
rescue ActiveRecord::StatementInvalid => error
errors.add(:value, "Somebody's already got that spot. Nudge it
by 1 and try again.")
This works fine on create, but when I call
Item.update_attribute(:bidup, <some integer>) it raises
"ArgumentError: wrong number of arguments (1 for 0)". I'm not deeply
attached to this way of doing things and would welcome any