Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Bid < ActiveRecord::Base
- belongs_to :user
- validate do |bid|
- check_fund
- end
- def check_fund
- user = User.find(self.user_id)
- errors.add(:user, "user's funds is insufficent") unless user.funds - self.txn > -1
- end
- end
Add Comment
Please, Sign In to add comment