瀏覽代碼

Supress the warning about the uniqueness validator

Akinori MUSHA 3 年之前
父節點
當前提交
21d28f5d88
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      app/models/user_credential.rb

+ 4 - 5
app/models/user_credential.rb

@@ -3,11 +3,10 @@ class UserCredential < ActiveRecord::Base
 
   belongs_to :user
 
-  validates_presence_of :credential_name
-  validates_presence_of :credential_value
-  validates_inclusion_of :mode, :in => MODES
-  validates_presence_of :user_id
-  validates_uniqueness_of :credential_name, :scope => :user_id
+  validates :credential_name, presence: true, uniqueness: { case_sensitive: true, scope: :user_id}
+  validates :credential_value, presence: true
+  validates :mode, inclusion: { in: MODES }
+  validates :user_id, presence: true
 
   before_validation :default_mode_to_text
   before_save :trim_fields