From 754e021047e5aeae9c7cebf1521d332be5f9da24 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 9 Aug 2011 06:14:03 -0400 Subject: [PATCH] adding sequel method that uses variables of multiple scopes --- .../02/passingdata/app/controllers/novel_controller.rb | 8 ++++++++ .../015/02/passingdata/app/views/novel/sequel.html.erb | 2 ++ cookbook/015/02/passingdata/config/routes.rb | 2 ++ 3 files changed, 12 insertions(+) create mode 100644 cookbook/015/02/passingdata/app/views/novel/sequel.html.erb diff --git a/cookbook/015/02/passingdata/app/controllers/novel_controller.rb b/cookbook/015/02/passingdata/app/controllers/novel_controller.rb index 47409de..6ead1d8 100644 --- a/cookbook/015/02/passingdata/app/controllers/novel_controller.rb +++ b/cookbook/015/02/passingdata/app/controllers/novel_controller.rb @@ -1,4 +1,8 @@ +$one = 1 + class NovelController < ApplicationController + $two = 2 + def index @title = 'Shattered View: a Novel on Rails' one_plus_one = 1 + 1 @@ -14,4 +18,8 @@ class NovelController < ApplicationController @counter += by end + def sequel + $three = 3 + end + end diff --git a/cookbook/015/02/passingdata/app/views/novel/sequel.html.erb b/cookbook/015/02/passingdata/app/views/novel/sequel.html.erb new file mode 100644 index 0000000..fd320c7 --- /dev/null +++ b/cookbook/015/02/passingdata/app/views/novel/sequel.html.erb @@ -0,0 +1,2 @@ +

Here they come, the counting numbers, +<%= $one %>, <%= $two %>, <%= $three %>.

diff --git a/cookbook/015/02/passingdata/config/routes.rb b/cookbook/015/02/passingdata/config/routes.rb index 4e2bc41..4b1aa65 100644 --- a/cookbook/015/02/passingdata/config/routes.rb +++ b/cookbook/015/02/passingdata/config/routes.rb @@ -1,4 +1,6 @@ Passingdata::Application.routes.draw do + get "novel/sequel" + get "novel/index" # The priority is based upon order of creation: