Hi everyone!
I’m writing concerning restful routes support using a custom parameter. For example,
resources :videos, param: :identifier
I think the feature is pretty awesome, but unfortunately I think it has a serious shortcoming. The great part is that requesting /videos/foobar
will correctly call VideosController#show
with a value of foobar
in params[:identifier]
.
But the not so good part is that if you try and generate a route to a given video, the identifier
attribute will be totally ignored and the id
will be used instead.
v = Video.create(identifier: "foobar")
app.video_path(v) # This would return "/videos/1"
I know the current answer to this is to override to_param
, but I think that’s not how it should be done. I opened a PR with more arguments behind my opinion, and a possible fix! I’d love to have some feedback