Re: validation

Le Sa
Mon, 15 Jun 2009 06:00:15 -0000

actually, if it is the same database, then there is no way to happen at
the same time, right?

I don''t know, maybe something like this:

class Tablet < ActiveRecord::Base

  validate :must_have_in_stock

  def must_have_in_stock
    qnt = Tablet.find(product_id).quantity
    erros.add(:quantity, ''There is only '' + qnt + ''
in stock.'')
        if quantity > qnt
  end
end