Module: Tramway::Core::TitleHelper

Defined in:
app/helpers/tramway/core/title_helper.rb

Instance Method Summary collapse

Instance Method Details

#default_titleObject



16
17
18
# File 'app/helpers/tramway/core/title_helper.rb', line 16

def default_title
  t('.title')
end

#page_title(action, model_name) ⇒ Object



20
21
22
23
24
25
26
# File 'app/helpers/tramway/core/title_helper.rb', line 20

def page_title(action, model_name)
  if I18n.locale == :ru
    t("helpers.actions.#{action}") + ' ' + genitive(model_name)
  else
    t("helpers.actions.#{action}") + ' ' + model_name.model_name.human.downcase
  end
end

#title(page_title = default_title) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'app/helpers/tramway/core/title_helper.rb', line 6

def title(page_title = default_title)
  if @application.present?
    title_text = "#{page_title} | #{@application.try(:title) || @application.public_name}"
    content_for(:title) { title_text }
  else
    error = Tramway::Error.new(plugin: :core, method: :title, message: 'You should set Tramway::Core::Application class using `::Tramway::Core.initialize_application model_class: #{model_class_name}` in config/initializers/tramway.rb OR maybe you don\'t have any records of application model')
    raise error.message
  end
end