Dynamic Title for your Rails App


Create Helper Method in application_helper.rb


 def full_title(page_title)
  base_title = "Your App Base Title"
  page_title.empty? ?  base_title : "#{base_title} | #{page_title}"
 end

Put this line in application.html.erb file


<title><%= full_title(yield :title)%></title>

In your view file like index.html.erb

<% content_for(:title, 'Home')%>
Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , ,
Posted in Html, html.erb

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: