rails / globalid

Identify app models with a URI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve Error When Converting Records without an Id

fny opened this issue · comments

Model.new.to_global_id currently raises a URI::InvalidComponentError with the message URI::InvalidComponentError: Expected a URI like gid://app/Person/1234: #<URI::GID gid://app>. An error particular to GlobalID would be useful:

GlobalID::UnidentifiableRecord Unable to identify #{record.class} without an id. (Maybe you forgot to call save?)

This is already being discussed in rails/rails#19861 and rails/rails#19877.

@fny your fix looks good. Maybe send a PR, to discuss more?

😁 dint catch #68