修复bid模型中budget的format报错的BUG

This commit is contained in:
sw 2014-10-15 16:49:48 +08:00
parent 9ba6fe13a3
commit 23ad3f26e4
1 changed files with 3 additions and 3 deletions

View File

@ -42,9 +42,9 @@ class Bid < ActiveRecord::Base
validates :author_id, presence: true
validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/}
validates :name, length: {maximum: NAME_LENGTH_LIMIT}
validates :budget,
format: {with : /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/, if: Proc.new { |p| p.reward_type == 1 }},
format: {with: /^(\d+)$|^(\d+).([0-9]{1})$/, if: Proc.new { |p| p.reward_type == 3 }}
validates :budget, format: { with: ->(p) { if p.reward_type == 1 then /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/
elsif p.reward_type == 3 then /^(\d+)$|^(\d+).([0-9]{1})$/ end } }
validate :validate_user
validate :validate_reward_type
after_create :act_as_activity