Account activation
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
-
51 end 52 53 # Activates an account. 54 def activate 55 update_columns(activated: true, activated_at: Time.zone.now) 56 end 57 58 # Sends activation email. 59 def send_activation_email 60 UserMailer.account_activation(self).deliver_now 61 end 62 63 private 64 65 # Converts email to all lower-case. 66 def downcase_email -
MasterEdited
indent, dòng này viết thẳng private
-
Master
đã sửa anh check rồi merge giùm em.
-
-
-
resolved all discussions
Toggle commit list -
-
-
40 42 def forget 41 43 update_attribute(:remember_digest, nil) 42 44 end 43 end 44 45 46 # Returns true if the given token matches the digest. 47 def authenticated?(attribute, token) 48 digest = send("#{attribute}_digest") 49 return false if digest.nil? 50 BCrypt::Password.new(digest).is_password?(token) 51 end 52 53 # Activates an account. 54 def activate 55 update_columns(activated: true, activated_at: Time.zone.now) -
Master
dùng
Time.currentsẽ an toàn hơn dùngTime.zone -
-
-
-
1 1 class User < ApplicationRecord 2 2 VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i 3 3 4 attr_accessor :remember_token 4 attr_accessor :remember_token, :activation_token 5 5 6 6 validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX } 7 7 validates :name, presence: true, length: { maximum: 50 }, uniqueness: { case_sensitive: false } -
Master
uniqueness: { case_sensitive: false }Sửa validate này cho email, không phải cho name. Hồi chapter 6 mình làm sai
-
-
-
-
Toggle commit list
-
merged
Toggle commit list