Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW DONE #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 32 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For all solutions, pretend that you have a model called `Cheese`.
```

```ruby
# your active record solution
cheeses.create({name: "Roquefort", color:"yellow", origin: "french", stink_level:5 } )
```

- Charolais, a white french cheese with a stink level of 5
Expand All @@ -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
Expand All @@ -37,15 +37,15 @@ 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
INSERT INTO cheeses (name, color, origin, stink_level) VALUES ('Teleme', 'white', 'American', 2);
```

```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!

Expand All @@ -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
Expand All @@ -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

Expand All @@ -78,16 +78,16 @@ 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
SELECT name FROM cheeses WHERE stink_level = 2;
```

```ruby
# your active record solution
cheese.where({stink_level: 2})
```
- Find all cheeses with a stink level of 10

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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'})
```


Expand All @@ -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"

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -201,53 +201,52 @@ The cheese game is changing constantly. Let's update our cheeses.
```

```ruby
# your active record solution
Durrus.destory
```

## Part 2: Review Today's Lesson:
Review the `README.md` file from today's lesson [here](https://github.com/WDI-HoneyBadger/w10d03-intro-to-rails) then answer the following questions:

- 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?
```
# 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
```