方法
實例公開方法
find_by_token_for(目的, 令牌) 連結
使用給定的 令牌
尋找記錄,以進行預定義的 目的
。如果令牌無效或找不到記錄,則傳回 nil
。
來源: 顯示 | 在 GitHub 上
# File activerecord/lib/active_record/token_for.rb, line 41 def find_by_token_for(purpose, token) raise UnknownPrimaryKey.new(self) unless model.primary_key model.token_definitions.fetch(purpose).resolve_token(token) { |id| find_by(model.primary_key => [id]) } end
find_by_token_for!(目的, 令牌) 連結
使用給定的 令牌
尋找記錄,以進行預定義的 目的
。如果令牌無效(例如過期、格式錯誤等),則提出 ActiveSupport::MessageVerifier::InvalidSignature
。如果令牌有效,但找不到記錄,則提出 ActiveRecord::RecordNotFound
。
來源: 顯示 | 在 GitHub 上
# File activerecord/lib/active_record/token_for.rb, line 50 def find_by_token_for!(purpose, token) model.token_definitions.fetch(purpose).resolve_token(token) { |id| find(id) } || (raise ActiveSupport::MessageVerifier::InvalidSignature) end