Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
Add product validations.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.trike.com.au/code/radiant/extensions/shopping_trike@63 dec4ba91-d232-0410-a499-b0f1e7490611
  • Loading branch information
tobin committed Jan 29, 2008
1 parent de600b9 commit 5e23a45
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/models/product.rb
@@ -1,5 +1,8 @@
class Product < ActiveRecord::Base
# tbd - dont allow products with the code "checkout"
# tbd - dont allow products with the code "cart"
# tbd - dont allow products with the code "eula"
validates_exclusion_of :code, :in => %w{checkout cart eula}
validates_presence_of :code

def validate
errors.add(:price, "should be a positive value") if price.nil? || price < 0.01
end
end

0 comments on commit 5e23a45

Please sign in to comment.