Sha256: 6389cf8fcdd0b6dc8b6c46fdb4b0482877e89b740f10435cf07554662eecccfa
Contents?: true
Size: 853 Bytes
Versions: 2
Compression:
Stored size: 853 Bytes
Contents
module Title module TitleHelper def title PageTitle.new(controller_path, action_name, controller.view_assigns.symbolize_keys).to_s end class PageTitle def initialize(controller_path, action_name, context) @controller_path = controller_path @action_name = action_name @context = context end def to_s I18n.t( [:titles, controller_name, action_name].join('.'), context.merge(default: [application_title, guess_title]) ) end private attr_reader :controller_path, :action_name, :context def application_title :'titles.application' end def guess_title Rails.application.class.to_s.split('::').first end def controller_name controller_path.gsub('/', '.') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
title-0.0.3 | app/helpers/title/title_helper.rb |
title-0.0.2 | app/title/helpers/title_helper.rb |