-
-
Save elyrly/6833429 to your computer and use it in GitHub Desktop.
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
| #Debugging | |
| (Use The Duck… ) | |
| --- | |
| Find the errors in the following | |
| 1.) | |
| > *My script is loading fine, but separate style sheets aren't working* | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="/script/script.js"></script> | |
| <link src="sytlesheet" type="text/css" href="/style/style.css"> | |
| </head> | |
| Comments: End with </html>; stylesheet is spelling incorrectly | |
| 2.) | |
| > *My scripts are loading, but they aren't working! How should I fix them? What's wrong?* | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/script" src="/script/script_1.js"></script> | |
| <script type="text/script" src="/script/script_2.js"></script> | |
| </head> | |
| Comments: | |
| ____ | |
| 3.) | |
| > *If the `CLICK ME` button is clicked twice what does the `console` display?* | |
| **html** (the error isn't here) | |
| … | |
| <button id="someId">CLICK ME</button> | |
| … | |
| **JS** | |
| … | |
| var count = 0; | |
| function clickAction(){ | |
| count += 1; | |
| console.log("hello "+ count) | |
| } | |
| document.getElementById("someId").onclick = clickAction() | |
| … | |
| _____ | |
| 4.) | |
| > *What's the error?* | |
| function countPlusTenSquared(){ | |
| var increment = 10; | |
| var count += increment; | |
| return count*count; | |
| } | |
| Comment: | |
| _____ | |
| 5.) | |
| > *Why is my form not working?* | |
| <form action="get" method="/"> | |
| <input type="text" name="my_name"> | |
| <input type="submit" value="submit name"> | |
| </form> | |
| Comment: get and / is reversed | |
| _____ | |
| 6.) | |
| > *My double route isn't working! Why isn't the route working?* | |
| … | |
| get "/double/:my_number" do | |
| input = params[:my_number] | |
| @double = 2*input | |
| erb :show | |
| end | |
| > *What does `get "/double/2"` return?* | |
| ________ | |
| 7.) | |
| > *My greet route isn't working! What should I change?* | |
| **app.rb** | |
| get "/greet/:name" do | |
| submitted_name = params[:name] | |
| erb :show | |
| end | |
| **show.erb** | |
| <div> | |
| Hello <%= submitted_name %>! | |
| </div> | |
| > *When I go to `/greet/world` expecting `Hello World!`, but I get the following error:* | |
| NameError at `/greet/world` | |
| undefined local variable or method `id' for | |
| #<Sinatra::Application:0x007f892315d160> | |
| BACKTRACE | |
| ____________________________________________ | |
| 2. <%= submitted_name %> | |
| ____ | |
| 8.) | |
| > *Is this RESTful?* | |
| >I have a site `http://somelist.com` that stores peoples names in a list. | |
| >I made the following routes | |
| GET '/name/new' # for showing a new form | |
| GET '/name/create' # for submiting a 'new' name form, | |
| # and creating | |
| GET '/name/:id/delete' # for submitting a deleting for a name | |
| GET '/name/:id/edit # for showing a new edit form | |
| GET '/name/:id/edit/post' # for submitting an edit | |
| # from a form | |
| Get- retrive data | |
| Post- create info database | |
| Put- update data | |
| Comment: Line 152 should be changed from a GET to a PUT; Line 154 should be changed from GET -> Post; Line 150 GET --> DELETE | |
| _____ | |
| 9.) | |
| > *What do you think of my controller? I don't even need a view. Why shouldn't I put all this in my controller?* | |
| get "/" do | |
| pageTitle = "myApp!" | |
| "<!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>#{pagetitle}</title> | |
| </head> | |
| <body> | |
| <div> | |
| Hello there! | |
| </div> | |
| </body> | |
| </html>" | |
| end | |
| Comment: From line [171..182] we should create a new /views/layout.erb | |
| ____ | |
| 10.) | |
| > *Look at my view! This works, but why should I be doing things this way?* | |
| `app.rb` | |
| get '/person/:name` do | |
| erb :show | |
| end | |
| `show.erb` | |
| <div> | |
| <% person = params[:name] %> | |
| Hello <%= person %> | |
| </div> | |
| Comment: line 194 should end in ' not `; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment