What is the best way to create a custom title for pages in a Rails app without using a plug-in?
I would like to add my pretty simple variant.
In the ApplicationController define this method:
def get_title
@action_title_name || case controller_name
when 'djs'
'Djs'
when 'photos'
'Photos'
when 'events'
'Various events'
when 'static'
'Info'
when 'club'
'My club'
when 'news'
'News'
when 'welcome'
'Welcome!'
else
'Other'
end
end
After that you can call get_title from your layout's title tag. You can define more specific title for your page by defining @action_title_name variable in your actions.