- Clone the code from github
git clone [email protected]:CoderAcademy-MEL/celebrities-app.git
- cdinto the new directory
| id | original_url | updated_at | created_at | |
|---|---|---|---|---|
| 1000000000 | http://google.com | YYYY-MM-DD HH:MM:SS | YYYY-MM-DD HH:MM:SS | 
| 21. Rails ActiveRecord Relation Part One | |
| https://recordings.roc2.blindsidenetworks.com/redhill/4025d6e81f003d55f1b99cd3ef71aafd4611dc50-1587595285808/notes/ | |
| 19. Ruby on Rails - Form Helpers | |
| https://recordings.roc2.blindsidenetworks.com/redhill/6a0e8d5f1c4f451c3bc1fd661126bfbe0850e549-1587422214897/notes/ | |
| 18. Ruby on Rails - Views | 
git clone [email protected]:CoderAcademy-MEL/celebrities-app.git
cd into the new directory| class Account | |
| attr_reader :owner | |
| def initialize(owner: nil) | |
| @owner = owner | |
| end | |
| end | |
| # we can safely try to access the address even without risk of getting a nil error | |
| # this first example throws an error | 
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Document</title> | |
| </head> | |
| <body> | |
| <h1>Selected task</h1> | |
| <p>Name: <%= @task["name"] %></p> | 
| require "sinatra" | |
| require "sinatra/json" | |
| require "erb" | |
| require "json" | |
| # in memory database but could replace this with sqlite | |
| tasks_database = [ | |
| { | |
| "id": 1, | |
| "name": "walk the dog", | 
| class School | |
| attr_reader :name, :students | |
| def initialize(name) | |
| @name = name | |
| @students = [] | |
| end | |
| def enroll(student) | |
| @students << student # "Jake" | |
| end | 
| # Q13 | |
| # The code snippet below looks for the first two elements that are out of order and swaps them; however, it is not producing the correct results. Rewrite the code so that it works correctly. | |
| arr = [5, 22, 29, 39, 19, 51, 78, 96, 84] | |
| index = 0 | |
| copy = arr[0..arr.length - 1] | |
| while index < arr.length - 1 | 
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Document</title> | |
| <link rel="stylesheet" href="./style.css"> | |
| </head> | |
| <body> | |
| <nav> | 
| def swap_first_items(arr) | |
| copy = arr[0..arr.length] | |
| i = 0 | |
| while i < arr.size - 1 | |
| if arr[i] > arr[i + 1] | |
| arr[i] = copy[i + 1] | |
| arr[i + 1] = copy[i] | |
| break | |
| end | |
| i += 1 |