Skip to content

Instantly share code, notes, and snippets.

@justinfrench
Created April 11, 2012 21:27
Show Gist options
  • Save justinfrench/2362758 to your computer and use it in GitHub Desktop.
Save justinfrench/2362758 to your computer and use it in GitHub Desktop.
Nestive
# Expected h1 title for posts#show is "My Blog :: My Post Title"
# --------------------------------------------------------------
# This was how it worked with `layout nil` in the controller
#
# posts_controller.rb
class PostsController
layout nil
end
# app/views/posts/show.html.erb
<% extends :blog %>
<% append :title, " :: My Post Title" %>
<% end %>
# app/views/layouts/blog.html.erb
<% extends :application %>
<% replace :title, "My Blog" %>
<% end %>
# app/views/layouts/application.html.erb
<h1><% area :title, "My Site" %></h1>
# --------------------------------------------------------------
# This was how it worked with controller layouts
#
# posts_controller.rb
class PostsController
layout "blog"
end
# app/views/posts/show.html.erb
# change: removed the extend block
<% append :title, " :: My Post Title" %>
# app/views/layouts/blog.html.erb
# no change
<% extends :application %>
<% replace :title, "My Blog" %>
<% end %>
# app/views/layouts/application.html.erb
# no change
<h1><% area :title, "My Site" %></h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment