└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Sinatra & Web Development Cheat Sheet 2 | 3 | This is a cheat sheet I developed for students while teaching an [Intro to Web Development](https://www.lighthouselabs.ca/intro-to-web) course through [Lighthouse Labs](https://www.lighthouselabs.ca). If you're interested in learning to code, you should definitely check them out. 4 | 5 | ## Table of Contents 6 | 7 | 1. [HTML](#html) 8 | - [Basic page structure](#basic-page-structure) 9 | - [Formatting tags](#formatting-tags) 10 | - [Content tags](#content-tags) 11 | - [Structural tags](#structural-tags) 12 | 2. [CSS](#css) 13 | - [Adding a stylesheet](#adding-a-stylesheet) 14 | - [Rule delcarations](#rule-declarations) 15 | - [Selectors](#selectors) 16 | - [Media queries](#media-queries) 17 | 3. [Ruby](#ruby) 18 | - [Ruby basics](#ruby-basics) 19 | - [Data types](#data-types) 20 | - [Complex data stores](#complex-data-stores) 21 | - [Logical operators](#logical-operators) 22 | - [Logic and conditions](#logic-and-conditions) 23 | - [Methods](#methods) 24 | 4. [Sinatra](#sinatra) 25 | - [Defining URLs](#defining-urls) 26 | - [Using a layout](#using-a-layout) 27 | - [Instance variables](#instance-variables) 28 | - [Partials](#partials) 29 | - [Helper methods](#helper-methods) 30 | - [Form data](#form-data) 31 | - [Sessions](#sessions) 32 | - [Interactive console (tux)](#interactive-console-tux) 33 | 5. [ActiveRecord](#activerecord) 34 | - [Defining a new class/object](#defining-a-new-classobject) 35 | - [Built-in methods](#built-in-methods) 36 | - [Defining relationships](#defining-relationships) 37 | - [Model validations](#model-validations) 38 | - [Updating values](#updating-values) 39 | 6. [Git](#git) 40 | 7. [Heroku](#heroku) 41 | 42 | 43 | ## HTML 44 | 45 | 46 | ### Basic page structure 47 | 48 | A basic HTML page will have the following structure, and the file will end with the `.html` extension (i.e. `mypage.html`). 49 | 50 | ```html 51 | 52 | 53 | 54 | Your Page Title 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | ``` 63 | 64 | _Tip: You can open HTML files directly in your browser without the need for Sinatra or any other kind of framework/backend - just double click the file and it'll open in your default web browser! If you're using Cloud9, go to Run -> Run With -> Apache httpd._ 65 | 66 | 67 | ### Formatting tags 68 | 69 | The following tags are used to format text and paragraphs. 70 | 71 | | HTML Tag | Purpose | Needs Closing Tag | Info/Example | 72 | | -------- | ------- | -------------------- | --------- | 73 | | `

` | Paragraph of text | Yes | [Link](http://www.w3schools.com/tags/tag_p.asp) | 74 | | `
` | Line break/pushes content to next line | No | [Link](http://www.w3schools.com/tags/tag_br.asp) | 75 | | `` | Bold text | Yes | [Link](http://www.w3schools.com/tags/tag_strong.asp) | 76 | | `` | Italic/emphasized text | Yes | [Link](http://www.w3schools.com/tags/tag_em.asp) | 77 | | `

` | Headings | Yes | [Link](http://www.w3schools.com/tags/tag_hn.asp) | 78 | | `` | Underlined text | Yes | [Link](http://www.w3schools.com/tags/tag_u.asp) | 79 | | `` | Strikethrough text | Yes | [Link](http://www.w3schools.com/tags/tag_s.asp) | 80 | 81 | 82 | ### Content tags 83 | 84 | These tags are used to insert interactive and fun elements into your page (so that it's more than just plain text). 85 | 86 | | HTML Tag | Purpose | Needs Closing Tag | Info/Example | 87 | | -------- | ------- | -------------------- | --------- | 88 | | `Link to Google` | Link to another page | Yes | [Link](http://www.w3schools.com/tags/tag_a.asp) | 89 | | `` | Displays an image | No | [Link](http://www.w3schools.com/tags/tag_img.asp) | 90 | | `
` | A form | Yes | [Link](http://www.w3schools.com/tags/tag_form.asp) | 91 | | `` | A generic input field | No | [Link](http://www.w3schools.com/tags/tag_input.asp) | 92 | | `` | A password field | No | [Link](http://www.w3schools.com/tags/tag_input.asp) | 93 | | `` | An email field | No | [Link](http://www.w3schools.com/tags/tag_input.asp) | 94 | | `