-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test to Home page #251
base: main
Are you sure you want to change the base?
Test to Home page #251
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is ready to have the finishing touches added to it in order for it to work - just requires the results functionality and a bit of tidying up indentation.
erb :index | ||
end | ||
|
||
post '/names' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation isn't in line with rest of code
@@ -0,0 +1,16 @@ | |||
<!DOCTYPE html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTML structure isn't required for ERB files to work
|
||
post '/names' do | ||
session[:player_name] = params[:player_name] | ||
redirect '/play' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be done without /names? Maybe in /play instead to save having to redirect the user?
<p>Make your selection: Rock, Paper or Scissors</p> | ||
|
||
<form action="/result" method="get" class="rps"> | ||
<input type="submit" value="Rock"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a button might be more helpful - "Input" does take a value but it might be more useful. Button requires a name, which can then be accessed by app.rb
end | ||
|
||
get '/result' do | ||
@player_name = session[:player_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation needs fixing
end | ||
|
||
get '/result' do | ||
@player_name = session[:player_name] | ||
erb :result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this, you should access the button/input value from the user (rock, paper or scissors).
You could then sample the three choices for the computer, and work out a result before returning to the Result page.
</head> | ||
<body> | ||
<%= @player_name %>, the results are in! | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs results
Made a small change