From 7f69d403883379f635feb67ed8448c8c9d94dc5e Mon Sep 17 00:00:00 2001 From: Jumanah Alharbi <44347549+jalharbi@users.noreply.github.com> Date: Tue, 22 Jan 2019 21:02:12 +0300 Subject: [PATCH 1/2] Update README.md --- README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 63832cc..8a80ab6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + # y ``` - Charolais, a white french cheese with a stink level of 5 @@ -217,37 +217,36 @@ Review the `README.md` file from today's lesson [here](https://github.com/WDI-Ho ``` - What kind of files belong in the `assets` directory? ``` - # your answer here - ``` + # it will be aplace where all of your CSS, JS, and image files belong. ``` - What does the command `rails db:drop` do? ``` - # your answer here + # Drops the database, if it exists ``` - What does the command `rails c` do? ``` - # your answer here + # opens a console to work within our rails environment ``` - What is an ORM? What does it stand for? ``` - # your answer here + # ORM stand for Object Relational Mapping , its allow us to comunicate with the database ``` - What does a migration file do? ``` - # your answer here + # you can add a file to edit the tables inside the database ``` - How do you run your migration files? ``` - # your answer here + # rails db:migrate ``` - How do you start a rails server? ``` - # your answer here + # rails s ``` - What is the command to start a new rails API called "reasons_why_ghadeer_rules"? ``` - # your answer here + # rails new reasons_why_ghadeer_rules -G --api --database=postgresql ``` - What is an API? ``` - # your answer here + # Its a website that share only data without views ``` From 7c8866d0ab01491493a001d388018832e260f42c Mon Sep 17 00:00:00 2001 From: jalharbi Date: Tue, 22 Jan 2019 22:01:37 +0300 Subject: [PATCH 2/2] HW DONE --- README.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 8a80ab6..732492c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # y + cheeses.create({name: "Roquefort", color:"yellow", origin: "french", stink_level:5 } ) ``` - Charolais, a white french cheese with a stink level of 5 @@ -28,7 +28,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheeses.create({name: "Charolais", color:"white ", origin: "french", stink_level:5 } ) ``` - Hooligan, a yellow American cheese with a stink level of 3 @@ -37,7 +37,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheeses.create({name: "Hooligan", color:"yellow", origin: "American", stink_level:3 }) ``` - Teleme, a white american cheese with a stink level of 2 ```sql @@ -45,7 +45,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheeses.create({name: "Teleme", color:"white", origin: "American", stink_level:2 }) ``` - And then we inserted a few more cheeses, but I think you get the point. Moving on! @@ -59,7 +59,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.all ``` - Find all the French cheeses @@ -69,7 +69,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where({origin: "French"}) ``` - Find all the English cheeses @@ -78,8 +78,8 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution - ``` + cheese.where({origin: "English"}) + ``` - Find all cheeses with a stink level of 2 ```sql @@ -87,7 +87,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where({stink_level: 2}) ``` - Find all cheeses with a stink level of 10 @@ -96,7 +96,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where({stink_level: 10}) ``` - Find all French cheeses with a stink level of 5 @@ -105,7 +105,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where({origin:"French" AND stink_level:5}) ``` - Find all Irish cheeses with a stink level of 6 @@ -114,7 +114,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where({origin:"Irish" AND stink_level:6}).select :id, :name ``` - Find all cheeses with a stink level of at least 4, but no greater than 8. @@ -123,7 +123,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where({stink_level >= 4 OR stink_level <=8 }) ``` - Find all American and English cheeses. @@ -132,7 +132,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where({origin:'American' OR origin:'English' }) ``` - Find all cheeses that are not from France. @@ -141,7 +141,7 @@ For all solutions, pretend that you have a model called `Cheese`. ``` ```ruby - # your active record solution + cheese.where.not({origin:'French'}) ``` @@ -156,7 +156,7 @@ The cheese game is changing constantly. Let's update our cheeses. ``` ```ruby - # your active record solution + Roquefort.update_attributes!({stink_level:3}) ``` - Change the color of Teleme to "mauve" @@ -165,7 +165,7 @@ The cheese game is changing constantly. Let's update our cheeses. ``` ```ruby - # your active record solution + Teleme.update_attributes!({color:'mauve'}) ``` - Delete the Hooligan cheese @@ -174,7 +174,7 @@ The cheese game is changing constantly. Let's update our cheeses. ``` ```ruby - # your active record solution + Hooligan.destroy ``` - Change the stink level of Stichelton to be 7 @@ -183,7 +183,7 @@ The cheese game is changing constantly. Let's update our cheeses. ``` ```ruby - # your active record solution + Stichelton.update_attributes!({stink_level:7}) ``` - Add the cheese "Monterey Jack", an American cheese with a stink level of 0 @@ -192,7 +192,7 @@ The cheese game is changing constantly. Let's update our cheeses. ``` ```ruby - # your active record solution + cheese.create({name:'Monterey Jack', color:'white',origin:'American', stink_level:0}) ``` - Delete Durrus @@ -201,7 +201,7 @@ The cheese game is changing constantly. Let's update our cheeses. ``` ```ruby - # your active record solution + Durrus.destory ``` ## Part 2: Review Today's Lesson: @@ -209,11 +209,11 @@ Review the `README.md` file from today's lesson [here](https://github.com/WDI-Ho - In express we built our routes inside of our controller, where do you put routes in a rails app? ``` - # your answer here + config/routes.rb ``` - Should a rails model be lower-case and plural, upper-case and plural, lower-case and singular, or upper-case and singular? ``` - # your answer here + lower-case singuler ``` - What kind of files belong in the `assets` directory? ```