修复bid模型中budget的format报错的BUG
This commit is contained in:
parent
9ba6fe13a3
commit
23ad3f26e4
|
@ -42,9 +42,9 @@ class Bid < ActiveRecord::Base
|
||||||
validates :author_id, presence: true
|
validates :author_id, presence: true
|
||||||
validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/}
|
validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/}
|
||||||
validates :name, length: {maximum: NAME_LENGTH_LIMIT}
|
validates :name, length: {maximum: NAME_LENGTH_LIMIT}
|
||||||
validates :budget,
|
validates :budget, format: { with: ->(p) { if p.reward_type == 1 then /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/
|
||||||
format: {with : /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/, if: Proc.new { |p| p.reward_type == 1 }},
|
elsif p.reward_type == 3 then /^(\d+)$|^(\d+).([0-9]{1})$/ end } }
|
||||||
format: {with: /^(\d+)$|^(\d+).([0-9]{1})$/, if: Proc.new { |p| p.reward_type == 3 }}
|
|
||||||
validate :validate_user
|
validate :validate_user
|
||||||
validate :validate_reward_type
|
validate :validate_reward_type
|
||||||
after_create :act_as_activity
|
after_create :act_as_activity
|
||||||
|
|
Loading…
Reference in New Issue