Add GamePolicy and integrate with the Game model
[cs356-p2-videostore.git] / app / models / game_policy.rb
diff --git a/app/models/game_policy.rb b/app/models/game_policy.rb
new file mode 100644 (file)
index 0000000..12eb47b
--- /dev/null
@@ -0,0 +1,15 @@
+class GamePolicy < ActiveRecord::Base
+  validates_presence_of :day
+  validates_presence_of :fee
+  validates_presence_of :period
+  validates_presence_of :description
+
+  validates_numericality_of :day
+  validates_numericality_of :fee
+  validates_numericality_of :period
+
+  protected
+  def validate
+    errors.add(:fee, "must be greater than $0.01") if fee < 0.01
+  end
+end