You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,7 +153,7 @@ Your numbers might be different but it should be more than 1.
153
153
154
154
# 2) Modify Views and Logging
155
155
156
-
Now that we have a bunch of users and associated products lets do something useful with them. Previously we noted that [localhost:3000/products](http://localhost:3000/products) was linked to the view `app/views/products/index.html.erb` through a route in our `config/routes.rb` file. Open the `index.html.erb` view now in a text editor (i recommend sublime text 2 for mac). Make sure your rails server is started (`$ rails server`) and visit [localhost:3000/products](http://localhost:3000/products) in your browser.
156
+
Now that we have a bunch of users and associated products, lets do something useful with them. Previously we noted that [localhost:3000/products](http://localhost:3000/products) was linked to the view `app/views/products/index.html.erb` through a route in our `config/routes.rb` file. Open the `index.html.erb` view now in a text editor (i recommend sublime text 2 for mac). Make sure your rails server is started (`$ rails server`) and visit [localhost:3000/products](http://localhost:3000/products) in your browser.
157
157
158
158
Add this to the top of the `index.html.erb` file:
159
159
@@ -162,7 +162,7 @@ Add this to the top of the `index.html.erb` file:
162
162
When you refresh your page you should see the new text:
163
163
164
164
165
-
If you don't go back and follow the prior steps.
165
+
If you don't, go back and follow the prior steps.
166
166
167
167
If you look in your rails server log (this is the code that gets spewed from terminal after you run `$ rails server`), you should be able to see a line in there that looks like this
168
168
@@ -171,15 +171,15 @@ If you look in your rails server log (this is the code that gets spewed from ter
171
171
172
172
(Note: we are using the `quiet_assets` gem, if you do this on another project your output will still have the same info, but it will also have a bunch of useless output for debugging as well.)
173
173
174
-
This is telling us that we are using a GET request on the url `/products` url, and since our routes have that mapped to `Products#index` in our routes.rb file our server log will tell us that combination of HTTP action and URL that we are looking at is located in the products controller and index action:
174
+
This is telling us that we are using a GET request on the `/products` url, and since our routes have that mapped to `products#index` in our routes.rb file, our server log will tell us that combination of HTTP action and URL that we are looking at is located in the products controller and index action:
175
175
176
176
Processing by ProductsController#index as HTML
177
177
178
-
Finally it will tell us that the view it rendered is coming from `products/index.html.erb` and that is is using the `laouts/application` file.
178
+
Finally it will tell us that the view it rendered is coming from `products/index.html.erb` and that is is using the `layouts/application` file.
179
179
180
180
Rendered products/index.html.erb within layouts/application (0.2ms)
181
181
182
-
We also learn that the request was a 200 response which is how computers say everything was good. If it was not a good response we might see a `404` or `500`reponse. On redirects we can expect a `301` or `302` response.
182
+
We also learn that the request was a 200 response which is how computers say everything was good. If it was not a good response we might see a `404` or `500`response. On redirects we can expect a `301` or `302` response.
183
183
184
184
Completed 200 OK in 7ms (Views: 6.7ms | ActiveRecord: 0.0ms)
185
185
@@ -190,25 +190,28 @@ All together the log looks like this:
190
190
Rendered products/index.html.erb within layouts/application (0.2ms)
191
191
Completed 200 OK in 7ms (Views: 6.7ms | ActiveRecord: 0.0ms)
192
192
193
-
There is alot of information in a tiny package. When things go wrong in your app you can use the log output to verify your assumptions are correct, and to get error messages.
193
+
There is a lot of information in a tiny package. When things go wrong in your app, you can use the log output to verify your assumptions are correct and to get error messages.
194
194
195
195
#### Homework:
196
196
197
-
Visit a [localhost:3000/users](http://localhost:3000/users) and then find the log entry. Then open up the readme.md you coppied onto your local machine and fill out this information:
197
+
Visit this url: [localhost:3000/users](http://localhost:3000/users) and then find the log entry. Then open up the readme.md you copied onto your local machine and fill out this information:
198
198
199
199
200
-
HTTP verb used in this request:
201
-
URL:
202
-
Controller Name:
203
-
Controller Action:
204
-
View File Name:
205
-
Layout File Name:
206
-
Response code of the request:
200
+
HTTP verb used in this request: Get
201
+
URL: /users
202
+
Controller Name: UsersController
203
+
Controller Action: index
204
+
View File Name: users/index.html.erb
205
+
Layout File Name: layouts/application
206
+
Response code of the request: 200
207
207
208
208
You should also notice a new line or two that we didn't see before, what is it (copy and paste, hint: after User Load) ?
0 commit comments