hashid-rails
hashid-rails copied to clipboard
ArgumentError: invalid range "r-0" in string transliteration
I ran into this rare issue where I have a model PlaylistTrack
and when I call find(id)
it throws this error: ArgumentError: invalid range "r-0" in string transliteration
.
The error is thrown from the hashids gem with @guards
being "r-0"
https://github.com/peterhellberg/hashids.rb/blob/b729fe514e492e18d9f69473b53eb59a3b5aee4b/lib/hashids.rb#L117
The issue was resolved after adding an explicit pepper to something else instead of the implicit "playlist_tracks"
:
class PlaylistTrack < ApplicationRecord
include Hashid::Rails
hashid_config pepper: "playlisttracks"
...
end
Using this pepper resulted in the @guards
being "y7d"
instead which is accepted.
I guess its just by chance that "playlist_tracks"
produces a problematic pepper but this could potentially be a problem with other table names as well.