Ruby on Rails Sunday, January 14, 2018

app/views/layouts/application.html.erb is rendered around your code, and do in the example above your page title is Title15 if I remember correctly.

If you want a dynamic page title you can put a line in the file such as

<%= render(:header_title) %>

in the head section of application.html., then you can use the following line in your underlying erb files

<% content_for(:header_title) do %>
<title>This is the page title</title>
<% end %>

What ever is in the block will be rendered in the header section (it could be html or JavaScript, or anything else that is valid where the render line is placed

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/71786c19-4d08-4625-b845-7c6fbc78bcda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment