Module: TitleHelper

Defined in:
app/helpers/title_helper.rb

Instance Method Summary collapse

Instance Method Details

#page_title(text = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/title_helper.rb', line 2

def page_title(text=nil)
	title = text.to_s

	if text.nil?
		if action_name == 'update'
			title = t("page_titles.#{controller_name}.edit")
		end

		if action_name == 'create'
			title = t("page_titles.#{controller_name}.new")
		end

		title = t("page_titles.#{controller_name}.#{action_name}", default: title)
	end

	if text.is_a? Symbol
		title = t("page_titles.#{controller_name}.#{text}")
	end

	content_for :title, "<div class=\"page-header\"><h1>#{title}</h1></div>".html_safe
	 :title, "#{"#{title} |" unless title.blank?} #{t :application_title}"
end