I'm using the gem friendly_id
in rails 4 to make nice urls for my user's product listings. It works by overriding the to_param
. Now it is working wonderfully in the Shop
namespace which is the public facing part of my site however in the Admin
namespace I'd rather be using the regular ids because I don't need them there and I'd rather the urls be shorter.
I thought this would be easy but after digging it actually seems somewhat complicated. The to_param
, because it's part of the model, has no real concept of what controller it is being called in. So the only option I see is to override url_for
so it uses id
in the Admin
namespace. I'm not sure how to do that and if that really is the best coarse of action because messing with url_for
seems a little dangerous.