lundi 13 mars 2017

Rails 3: Get helper_url from path

I am trying to get the helper_url from the current path. For example if I have the following route:

get "user/:user_id" => 'user#user_info', :as => 'user_information'

If I visit user/31221, is there any way for me to get the helper_url user_information or the string "user/:user_id" (not "user/31221") from the url?

I can get the controller and the action with Rails.application.routes.recognize_path(request.env['PATH_INFO']), but I am not able to get the rest of this information. I can do it with rake routes but I want to do this for a very specific logging purpose.

Aucun commentaire:

Enregistrer un commentaire