Commit 6545291f by Đường Sỹ Hoàng

Fixed order of method in line 12 & remove comments

parent 9c586237
class User < ApplicationRecord class User < ApplicationRecord
def User.digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost)
end
# Constant
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
# Validation macros
validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX } validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX }
validates :name, presence: true, length: { maximum: 50 }, uniqueness: { case_sensitive: false } validates :name, presence: true, length: { maximum: 50 }, uniqueness: { case_sensitive: false }
validates :password, presence: true, length: { minimum: 6 } validates :password, presence: true, length: { minimum: 6 }
...@@ -16,4 +8,9 @@ class User < ApplicationRecord ...@@ -16,4 +8,9 @@ class User < ApplicationRecord
before_save { email.downcase! } #Call Backs before_save { email.downcase! } #Call Backs
has_secure_password has_secure_password
def User.digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost)
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment