How to override routes path helper in rails?
问题 My route is defined like this match '/user/:id' => 'user#show', :as => :user If for some reason a nil ID is passed I want the route helper to return only '#' and if ID is not nil i want it to return normal path like '/user/123'. or is there any better way to do it. this route helper has been used in lot of places in my code so I dont want to change that. Instead I am looking for one place which will effect all instances of user_path. Thanks 回答1: module CustomUrlHelper def user_path(user,