token = user.to_sgid(expires_in: 1.hour, for: 'reasons', constraint: 2).to_s
GlobalID::Locator.locate_signed(token, for: 'reasons', constraint: 3) == user # true
GlobalID::Locator.locate_signed 不尊重創建時傳入的其他約束。如何根據附加約束進行過濾?
uj5u.com熱心網友回復:
約束仍然保存在 SignedGlobalID.uri
因此SignedGlobalID.parse(token, for: 'reasons').uri.params將回傳一個包含所有引數的哈希。添加流控制以決定根據此哈希檢索物件。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/443725.html
標籤:轨道上的红宝石
上一篇:Rails嵌套包含動態類
下一篇:Hash#dig未按預期進行評估
