First of all, when you say #{controller.controller_name}
, it means that you have an object called controller
, accessible from your view, which is incorrect. Even if you manage to access the controller and the name of its action, I do not think that it is worth the effort and time.
Instead, you can structure your translation file like this:
views: model_name (parkings): "Parkings" action_1_name (index): "Parkings Index" action_2_name (new): "New Parking" ...
and, in your opinion, say (for example) <%= link_to (t "views.model_name.action_name"), :action %>
source share