From 23ad3f26e480ce0d3c1d448653f1f71ce6ea0d0c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Oct 2014 16:49:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbid=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E4=B8=ADbudget=E7=9A=84format=E6=8A=A5=E9=94=99=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/bid.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/bid.rb b/app/models/bid.rb index 038c45cd5..02569ade1 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -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