Commit 9f1a5f415a306261d7c6b66f3a4ca7f062e914a8
1 parent
2d162ff9
Exists in
master
and in
4 other branches
Key uniq method refactored
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
app/models/key.rb
@@ -24,7 +24,7 @@ class Key < ActiveRecord::Base | @@ -24,7 +24,7 @@ class Key < ActiveRecord::Base | ||
24 | end | 24 | end |
25 | 25 | ||
26 | def unique_key | 26 | def unique_key |
27 | - query = Key.where('`key` = ?', key) | 27 | + query = Key.where(:key => key) |
28 | query = query.where('(project_id IS NULL OR project_id = ?)', project_id) if project_id | 28 | query = query.where('(project_id IS NULL OR project_id = ?)', project_id) if project_id |
29 | if (query.count > 0) | 29 | if (query.count > 0) |
30 | errors.add :key, 'already exist.' | 30 | errors.add :key, 'already exist.' |