I have a nested resource in users:
resources :users do
resources :reservations
end
In my controller actions i can get the current controller name by using controller.controller_name. So in the user show action the controller.controller_name returns "users". Likewise in the reservations show action it returns "reservations".
But when i'm a the nested resource route like "http://mywesite/users/:id/mutations" i would like to get the parent controller of the nested resource, in this case "users". Is there any way in retrieving this using a controller property or route checker? I'm not a fan of regex my url.
I could check my params[:user_id], but could this be error prone? I might have an registrations controller in which the :user_id could be set.
The reason I want to have this parent resource is because i want to create a search form in my layout only when the current action has something to do with users, e.g. all actions that are performed in the users controller or nested resources controller of the users.