I have never found a good solution for the following problem. I have the usual structure:
namespace :admin do
When I call content_path(content) I want the id to be the slug of the content, while when I call admin_content_path(content) I want the id to be the id of the content. I just want the id not to be related on the model (actually the id is the returning value of the to_param method of the model), but on the route.
I know I can write admin_content_path(id: content.id) or content_path(id: content.slug), but this is just an hack actually. Also, this is especially annoying in form_for, since I can’t write
but I’m forced to use
form_for @content, url: @content.new_record? ? admin_contents_path : admin_contents_path(id: @content.id)