I18n access ".title" key with view context in layout
Hi!
I try to create a small view helper to manage content for `<title>`.
I try to create a small view helper to manage content for `<title>`.
module ApplicationHelper def page_title(options = {}) app_name = Rails.application.class.to_s.split("::").first key = "#{controller_name}.#{action_name}.title" title = content_for(:page_title) || t(key, default: "") [app_name, title].join(" : ") end end
I use high_voltage gem. If I do `t(".title")` it attempt to call `en.pages.about.title` and in my helper it attempt to call `en.pages.show.title`.
I try to found a method to use instead `action_name` to get `about` instead `show` but I didn't found.
I looked the rails code and found this method is used, but I can't access to the `@virtual_path`.
I think there is a proper way to do this, but I didn't found for now.
Does somebody has any idea?
Thanks!
In fact `@virtual_path` is accessible inside `ApplicationHelper`. But it returns the path for the layout.
So finally what I would like, is to know the view name of the view called in the action controller.
So finally what I would like, is to know the view name of the view called in the action controller.