Route a resource where the name can be anything, including .
and /
charts, eg:
- ...And You Will Know Us by the Trail of Dead
- GZA/Genius
Assuming there is the model Artist.create(name: 'GZA/Genius')
If you visit /artists/GZA%2FGenius
(manually constructued/properly escaped) then app will route you to the right controller/action, and the value of params[:id]
will be GZA/Genius
. All is good.
If you call artist_path
for that model you'll get a UrlGenerationError
:
No route matches {:action=>"show", :controller=>"artists", :id=>#<Artist id: 57, name: "GZA/Genius">} missing required keys: [:id]```
My guess is that it's trying to match the route before escaping `name`, so is trying to match a route like `/artist/GZA/Genius`, which doesn't exist.
(I'm still getting to grips with a lot of Rails, so it's not immediately clear if this is a rails, friendly id or me (likely) issue.)
If
constraints
is removed then it works as expected, but then artist names with a.
in them, eg:/artists/...And%20You%20Will%20Know%20Us%20by%20the%20Trail%20of%20Dead
, thenparam[:id]
in the controller is..
, as the rest is taken as format.