From 3f5e4819063628597d49ad62988cf80d4eabc4f2 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 9 Aug 2011 06:41:10 -0400 Subject: [PATCH] specifying separate layouts within controllers and methods --- .../015/hodgepodge/app/controllers/foo_controller.rb | 7 +++++++ cookbook/015/hodgepodge/app/views/foo/count.html.erb | 2 ++ .../hodgepodge/app/views/layouts/application.html.erb | 6 +++--- cookbook/015/hodgepodge/app/views/layouts/bar.html.erb | 9 +++++++++ cookbook/015/hodgepodge/app/views/layouts/count.html.erb | 9 +++++++++ cookbook/015/hodgepodge/config/routes.rb | 2 ++ 6 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 cookbook/015/hodgepodge/app/views/foo/count.html.erb create mode 100644 cookbook/015/hodgepodge/app/views/layouts/bar.html.erb create mode 100644 cookbook/015/hodgepodge/app/views/layouts/count.html.erb diff --git a/cookbook/015/hodgepodge/app/controllers/foo_controller.rb b/cookbook/015/hodgepodge/app/controllers/foo_controller.rb index 392a279..cc2ac14 100644 --- a/cookbook/015/hodgepodge/app/controllers/foo_controller.rb +++ b/cookbook/015/hodgepodge/app/controllers/foo_controller.rb @@ -1,5 +1,12 @@ class FooController < ApplicationController + layout 'bar' + def index end + def count + @data = [1,2,3] + render :layout => 'count' + end + end diff --git a/cookbook/015/hodgepodge/app/views/foo/count.html.erb b/cookbook/015/hodgepodge/app/views/foo/count.html.erb new file mode 100644 index 0000000..989eaad --- /dev/null +++ b/cookbook/015/hodgepodge/app/views/foo/count.html.erb @@ -0,0 +1,2 @@ +

Foo#count

+

Find me in app/views/foo/count.html.erb

diff --git a/cookbook/015/hodgepodge/app/views/layouts/application.html.erb b/cookbook/015/hodgepodge/app/views/layouts/application.html.erb index caf0829..14d6924 100644 --- a/cookbook/015/hodgepodge/app/views/layouts/application.html.erb +++ b/cookbook/015/hodgepodge/app/views/layouts/application.html.erb @@ -1,8 +1,8 @@ - - My Website - <%= @title %> - + + My Website - <%= @title %> + <%= yield %> diff --git a/cookbook/015/hodgepodge/app/views/layouts/bar.html.erb b/cookbook/015/hodgepodge/app/views/layouts/bar.html.erb new file mode 100644 index 0000000..5dff588 --- /dev/null +++ b/cookbook/015/hodgepodge/app/views/layouts/bar.html.erb @@ -0,0 +1,9 @@ + + + + BAR :: My Website - <%= @title %> + + + <%= yield %> + + diff --git a/cookbook/015/hodgepodge/app/views/layouts/count.html.erb b/cookbook/015/hodgepodge/app/views/layouts/count.html.erb new file mode 100644 index 0000000..3fa27c6 --- /dev/null +++ b/cookbook/015/hodgepodge/app/views/layouts/count.html.erb @@ -0,0 +1,9 @@ + + + + COUNT :: My Website - <%= @title %> + + + <%= yield %> + + diff --git a/cookbook/015/hodgepodge/config/routes.rb b/cookbook/015/hodgepodge/config/routes.rb index ce31f9e..89b9e00 100644 --- a/cookbook/015/hodgepodge/config/routes.rb +++ b/cookbook/015/hodgepodge/config/routes.rb @@ -1,4 +1,6 @@ Hodgepodge::Application.routes.draw do + get "foo/count" + get "foo/index" # The priority is based upon order of creation: