run_cl 1.0.22 → 1.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,11 @@ class UniqRunValidator < ActiveModel::Validator
4
4
  def validate record
5
5
  options[:attributes].each do |attribute|
6
6
  run = Run.remove_format record.send(attribute)
7
- record.errors[attribute.to_sym] << 'ya está en uso!!!' if record.class.where(attribute => run).any?
7
+ if record.new_record?
8
+ record.errors[attribute.to_sym] << 'ya está en uso!!!' if record.class.where(attribute => run).any?
9
+ else
10
+ record.errors[attribute.to_sym] << 'ya está en uso!!!' if record.class.where('? = ? AND id != ?', attribute, run, record.id).any?
11
+ end
8
12
  end
9
13
  end
10
14
 
@@ -1,3 +1,3 @@
1
1
  module RunCl
2
- VERSION = "1.0.22"
2
+ VERSION = "1.0.23"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 22
9
- version: 1.0.22
8
+ - 23
9
+ version: 1.0.23
10
10
  platform: ruby
11
11
  authors:
12
12
  - mespina
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-03-22 00:00:00 -04:00
17
+ date: 2013-03-25 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20