Last active
August 29, 2015 13:57
-
-
Save mathildathompson/9405669 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
| class Sandwich | |
| @slices_of_bread = 2 | |
| def how_much_bread() | |
| @slices_of_bread | |
| end | |
| end | |
| #Instance variable you can access anywhere inside the class; | |
| $mustard | |
| #global variable available anywhere in the program; | |
| #Something can go badly wrong when global variables override each other; | |
| get '/students/:first_name' do | |
| #Inside this you can access the params hash params[:first_name] | |
| erb :students | |
| end | |
| get '/hello' | |
| #Inside here params is in this state params = {} | |
| end | |
| /students/erik?color=emo | |
| #Before the question mark is the reseource and after the question mark is the query string; | |
| #If the key in the resource and the key in the query string are the same the ket in the resource will override the key in the query string; | |
| <form action="/post?hotdog=ladies+pink+hot" method="post"> | |
| <input = "color" name="color"> | |
| </form> | |
| # The params inside the form will override the params inside the URL; | |
| ##LINKS.CSV | |
| #Commas separating the columns (make sure you have no spaces between the commas); | |
| #You can push a hash into an array: | |
| links = [] | |
| links.push({ | |
| :url => parts[0], | |
| :text => parts[1] | |
| }) | |
| #Something that is always unique is the current time; | |
| #We count the number of seconds since the EPOCH Jan 1st 1970; | |
| #To work out the current date, they work out how many days since the Epoch; | |
| Time.now.to_i #Everytime you request this the number goes up | |
| f = File.new("receipt=#{ Time.now.to_i}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment