Skip to content

Commit e3df32f

Browse files
committed
docs
1 parent 1a7727c commit e3df32f

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ Note directions that start with `$` indicate they are on the command line, you s
1010

1111
## Fork & Clone
1212

13+
Go to the directory where you like to store your rails code.
14+
1315
Fork this project and then clone it to your local machine.
1416

1517

18+
## Ruby
19+
20+
You will need ruby 1.9 or higher for this example. You can check your version of Ruby by running:
21+
22+
$ ruby -v
23+
1624
## Install
1725

1826
Once on your local machine you will need to navigate to the project directory and run:
1927

2028
$ bundle install
29+
30+
This might take awhile, afterwards you will need to run:
31+
2132
$ rake db:create
2233
$ rake db:migrate
2334

@@ -36,7 +47,7 @@ This means that if you visit [localhost:3000/products](http://localhost:3000/pro
3647

3748
## 1) Populating Data
3849

39-
If you didn't already create a user by visiting [localhost:3000/users/new](http://localhost:3000/users/new) filling out the form and hitting submit.
50+
If you didn't already, create a user by visiting [localhost:3000/users/new](http://localhost:3000/users/new) filling out the form and hitting submit.
4051

4152
In a new terminal run the rails console:
4253

@@ -58,16 +69,22 @@ From here we can use our rails code and populate our database and perform querie
5869
Now that you've got a user in your database lets make sure we can find them again with SQL. Take the name entered above (in this case `richard`) and search the database for it:
5970

6071

72+
> User.first.name
73+
=> 'richard'
6174
> User.where(:name => 'richard')
6275
=> [#<User id: 1, name: "richard", ... >]
6376

6477
Great that found ALL of the users named 'richard', if you got an empty array try again, make sure to use the name you used. If we wanted to find only one richard, we could limit the query and pull out the first user like this:
6578

79+
> User.first.name
80+
=> 'richard'
6681
> User.where(:name => 'richard').first
6782
=> #<User id: 1, name: "richard", ... >
6883

6984
Cool, now we can store that user to a variable to use later:
7085

86+
> User.first.name
87+
=> 'richard'
7188
> rich = User.where(:name => 'richard').first
7289
> rich.name
7390
=> "richard"
@@ -82,7 +99,7 @@ If you look in the user model `apps/models/user.rb` you will see that users have
8299
You will see that each product contains a foreign key called `user_id` lets add a product to our user. Using the existing variable from previously we can see all of our user's products:
83100

84101
> rich = User.where(:name => 'richard').first
85-
> puts rich.products
102+
> rich.products
86103
=> []
87104

88105
There aren't any yet, so lets make one

0 commit comments

Comments
 (0)