Module: Tramway::Core::TitleHelper

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

Instance Method Summary collapse

Instance Method Details

#default_titleObject



14
15
16
# File 'app/helpers/tramway/core/title_helper.rb', line 14

def default_title
  t('.title')
end

#page_title(action, model_name) ⇒ Object



18
19
20
# File 'app/helpers/tramway/core/title_helper.rb', line 18

def page_title(action, model_name)
  t("helpers.actions.#{action}") + ' ' + genitive(model_name)
end

#title(page_title = default_title) ⇒ Object



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

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'))
    raise error.message
  end
end