Skip to content

Instantly share code, notes, and snippets.

@illbzo1
Created December 14, 2011 02:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save illbzo1/1474984 to your computer and use it in GitHub Desktop.
Save illbzo1/1474984 to your computer and use it in GitHub Desktop.
Working with form methods in Sinatra
<form method="get" action="/input">
<input type="text" name="input" />
<input type="submit" value="Submit" />
</form>
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
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
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