Created
December 14, 2011 02:33
-
-
Save illbzo1/1474984 to your computer and use it in GitHub Desktop.
Working with form methods in Sinatra
This file contains hidden or 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
<form method="get" action="/input"> | |
<input type="text" name="input" /> | |
<input type="submit" value="Submit" /> | |
</form> |
This file contains hidden or 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
get '/input' do | |
@input = params[:input] | |
end | |
get '/' do | |
@torch_room = torch_room | |
@location == @torch_room | |
case @input | |
when "go northwest" | |
redirect "/chest_room" | |
when "go north" | |
redirect "/dais_room" | |
when "go northeast" | |
redirect "/orb_room" | |
else | |
puts "I don't understand what you just said." | |
erb :torch_room | |
end | |
end |
This file contains hidden or 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
get '/input' do | |
@input = params[:input] | |
case @location | |
when @torch_room | |
case @input | |
when "go northwest" | |
redirect "/chest_room" | |
when "go north" | |
redirect "/dais_room" | |
when "go northeast" | |
redirect "/orb_room" | |
else | |
puts "I don't understand what you just said." | |
erb :torch_room | |
end | |
end | |
end |
This file contains hidden or 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
get '/input' do | |
@input = params[:input] | |
case @location | |
when @torch_room | |
case @input | |
when "go northwest" | |
redirect "/chest_room" | |
when "go north" | |
redirect "/dais_room" | |
when "go northeast" | |
redirect "/orb_room" | |
else | |
puts "I don't understand what you just said." | |
erb :torch_room | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment