RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: holyketzer
Site: http://brainstorage.me/ketzer
Great idea! Thanks a lot Ryan!!! Before I put header global variable in a controller (((
For layout:
... <title>My Site - <%= yield_or_default(:title, "Default title") %></title> ...
and view:
... <% title "My page title" %> ...
It doesn't work on rails 3.1.1
module ApplicationHelper def title(page_title) content_for (:title) { page_title } end def yield_or_default(section, default = "") content_for?(section) ? yield(section) : default end end
Solve:
module ApplicationHelper def title(page_title) content_for (:title) { page_title } end def yield_or_default(section, default = "") content_for?(section) ? content_for(section) : default end end
Great idea! Thanks a lot Ryan!!! Before I put header global variable in a controller (((
For layout:
and view:
It doesn't work on rails 3.1.1
Solve: