0
사용자 모델이 있으며 사용자가 계정을 만들면 확인 용 링크가있는 편지가 전자 메일 주소로 전송됩니다. after_callback
은 사용자의 confirmed
열을 false
으로 설정합니다. 는콜백 후 작동하지 않음
User.rb (I는 한 종류의 하나 이상의 콜백 가능한 경우, 콜백 후 2가 확실하지 않습니다) :
after_create :confirmation
after_create :add_user_profile
...
def confirmation
if self.guest
self.confirmed=true
elsif self.authentication
self.confirmed=true
else
self.confirmed=false
begin
confirmation_token = SecureRandom.urlsafe_base64
end while User.exists?(:confirmation_token => confirmation_token)
self.confirmation_token=confirmation_token
self.confirmation_link_sent_at=Time.now.utc
UserMailer.send_confirmation_link(self).deliver
User.delay.delete_unconfirmed(self)
end
end
하지만 콘솔에서 마지막 사용자를 출력 할 때 :
>> User.last
User Load (1.0ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
#<User id: 21, email: "[email protected]", password_digest: "$2a$10$LMtsumUaS5MaiRhz3.mZ2em7Fbt3.66pbpe4863zj3b0...", created_at: "2013-05-22 17:17:18", updated_at: "2013-05-22 17:17:18", guest: false, auth_token: "lbIJftEqgwyXYymjEVdhCQ", password_reset_token: nil, password_link_sent_at: nil, confirmed: nil, confirmation_token: nil, confirmation_link_sent_at: nil>
확인 된 것처럼 nil , 다른 관련 칼럼도 있습니다. 왜?
감사합니다. 항상 그런 일이 있은 후에 구원을 요청해야한다는 것을 잊어 버려야합니다. –