instance method
find_signed!
Ruby on Rails 7.2.3
Since v6.1.7.10Signature
find_signed!(signed_id, purpose: nil)
Works like find_signed, but will raise an ActiveSupport::MessageVerifier::InvalidSignature exception if the signed_id has either expired, has a purpose mismatch, is for another record, or has been tampered with. It will also raise an ActiveRecord::RecordNotFound exception if the valid signed id can’t find a record.
Examples
User.find_signed! "bad data" # => ActiveSupport::MessageVerifier::InvalidSignature signed_id = User.first.signed_id User.first.destroy User.find_signed! signed_id # => ActiveRecord::RecordNotFound
Parameters
-
signed_idreq -
purposekey = nil
Source
# File activerecord/lib/active_record/signed_id.rb, line 72
def find_signed!(signed_id, purpose: nil)
if id = signed_id_verifier.verify(signed_id, purpose: combine_signed_id_purposes(purpose))
find(id)
end
end
Defined in activerecord/lib/active_record/signed_id.rb line 72
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::SignedId::ClassMethods