Sha256: 985fc84fb19e5a626bf09a781f54f0445b3f0491d0d7f8263b3985d94d2da627

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
camping-3.2.6 test/apps/forward_to_other_controller.rb
camping-3.2.5 test/apps/forward_to_other_controller.rb
camping-3.2.4 test/apps/forward_to_other_controller.rb
camping-3.2.3 test/apps/forward_to_other_controller.rb
camping-3.2.2 test/apps/forward_to_other_controller.rb
camping-3.2.1 test/apps/forward_to_other_controller.rb
camping-3.2.0 test/apps/forward_to_other_controller.rb
camping-3.1.3 test/apps/forward_to_other_controller.rb
camping-3.1.2 test/apps/forward_to_other_controller.rb
camping-3.1.0 test/apps/forward_to_other_controller.rb
camping-3.0.2 test/apps/forward_to_other_controller.rb
camping-3.0.1 test/apps/forward_to_other_controller.rb
camping-3.0.0 test/apps/forward_to_other_controller.rb
camping-2.1.532 test/apps/forward_to_other_controller.rb
camping-2.1.531 test/apps/forward_to_other_controller.rb
camping-2.1.523 test/apps/forward_to_other_controller.rb
camping-2.1.467 test/apps/forward_to_other_controller.rb
camping-2.1 test/apps/forward_to_other_controller.rb
camping-2.0 test/apps/forward_to_other_controller.rb
camping-2.0.rc0 test/apps/forward_to_other_controller.rb