Skip to content

Instantly share code, notes, and snippets.

@Shiggiddie
Last active December 16, 2015 02:59
Show Gist options
  • Save Shiggiddie/643e7153605354b84686 to your computer and use it in GitHub Desktop.
Save Shiggiddie/643e7153605354b84686 to your computer and use it in GitHub Desktop.
Ruby/Rails HW: get/post routes, passing parameters into .erb templates, .erb if/else template logic
# 1) Make necessary modifications to a rails project such that an HTML response of "<h1>Hello World</h1>"
# is returned when hitting the path "/hello_world/index" with a GET request
# 2) Devise a shell utility "curl" command that makes a GET request of the path constructed in #1
# 3) Make necessary modifications to the rails project such that an HTML response of "<h1>Hello POST world</h1>"
# is returned when hitting the path "/hello_world/index" with a POST request, do not remove any code created in #1
# 4) Devise a shell utility "curl" command that makes a POST request of the path constructed in #2
# 5) Make necessary modifications to the rails project such that an HTML response of "<h1>Hello POST world PLUS</h1>"
# is returned when hitting the path "hello_world/index" with a POST request AND a payload that contains the key/value pair
# "plus"/"true", otherwise the HTML response should be "<h1>Hello POST world NO-PLUS</h1>"
# 6) Devise two shell utility "curl" commands that invoke the two different responses described in #5
# 7) Make necessary modifications to the rails project such that the POST request from #5 is able to handle requests
# for both HTML and JSON renderings. For the HTML rendering, handle exactly the same as #5. For the JSON rendering,
# respond with a JSON object that contains the key/value pair "plus"/<"true" or "false", depending on the value of the
# payload "plus" value.
# 8) Devise two more shell utility "curl" commands tha tinvoke the two different JSON responses described in #7, also use
# the two shell utility "curl" commands devised in #6 to prove that they still work
@rgsoto
Copy link

rgsoto commented Apr 30, 2015

  1. curl -X POST "http://localhost:3000/hello/index" -d ""

Hello POST World

Reni:pause_pray_2 (dick) [2.1.1]$

@rgsoto
Copy link

rgsoto commented Apr 30, 2015

  1. curl -X POST "http://localhost:3000/hello/index" -d "plus=hjdgadjhgf"

Hello POST world PLUS

Reni:pause_pray_2 (dick) [2.1.1]$ curl -X POST "http://localhost:3000/hello/index" -d "plus="

Hello POST world PLUS

Reni:pause_pray_2 (dick) [2.1.1]$ curl -X POST "http://localhost:3000/hello/index" -d ""

Hello POST world NO-PLUS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment