-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now sends all key/value pairs in h since it contains the Hash from th…
…e a argument. Also created a small test apps to illustrate the controller forwarding mechanis.
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
gem 'camping', '=1.9.316' | ||
require 'camping' | ||
|
||
Camping.goes :ForwardToOtherController | ||
|
||
module ForwardToOtherController | ||
|
||
module Controllers | ||
|
||
class Index < R '/' | ||
attr_accessor :msg | ||
|
||
def get | ||
puts "msg=#{@msg}" | ||
puts "input=#{input.inspect}" | ||
render :index | ||
end | ||
end | ||
|
||
class Start < R '/start' | ||
def get | ||
render :start | ||
end | ||
end | ||
|
||
class Welcome < R '/welcome' | ||
def post | ||
if input.name == '_why' | ||
msg = "Wow you're back _why! This is front-page news!" | ||
r *ForwardToOtherController.get(:Index, :msg => msg, :input => input ) | ||
end | ||
|
||
@result = "Welcome #{input.name}!" | ||
render :welcome | ||
end | ||
end | ||
|
||
end | ||
|
||
module Views | ||
def index | ||
h1 @msg if @msg && !@msg.empty? | ||
a "Start", :href=> "/start" | ||
end | ||
|
||
def start | ||
h3 "Start" | ||
|
||
form :action=>R(Welcome), :method=>:post do | ||
label "Who are you?", :for=>:name | ||
div "Note: type _why if you want to test the forward logic otherwise just type your name", :style=>"color:green;font-size:8pt;" | ||
input :type=>:text, :name=>:name; br | ||
input :type=>:submit | ||
end | ||
end | ||
|
||
def welcome | ||
div "#{@result}" | ||
end | ||
end | ||
end |