1 00:00:00,000 --> 00:00:04,877 [MUSIC] 2 00:00:04,877 --> 00:00:08,509 We've set up our post resource and we're able to view posts in our browser. 3 00:00:08,509 --> 00:00:11,850 But what's actually happening when you load that URL? 4 00:00:11,850 --> 00:00:16,610 Your browser sends a request for the post resource and the web framework, Rails, 5 00:00:16,610 --> 00:00:20,350 has to send back a response with some HTML for the browser to display. 6 00:00:21,540 --> 00:00:24,960 Here's an overview of how Rails processes a request. 7 00:00:24,960 --> 00:00:28,500 Rails looks at the request to figure out which code should handle it. 8 00:00:28,500 --> 00:00:32,300 The request gets routed to action method on a controller. 9 00:00:32,300 --> 00:00:36,650 The controller loads the resource in from the database using a model class. 10 00:00:36,650 --> 00:00:39,460 Then the controller renders a view using the model data 11 00:00:39,460 --> 00:00:41,720 to generate the response content. 12 00:00:41,720 --> 00:00:46,971 To retrieve the URL http://localhost:3000/posts, 13 00:00:46,971 --> 00:00:50,660 your browser sends an HTTP get request. 14 00:00:50,660 --> 00:00:55,430 Your browser uses a communication standard called Hyper Text Transfer Protocol or 15 00:00:55,430 --> 00:00:58,290 HTTP to talk to web servers. 16 00:00:58,290 --> 00:01:00,935 That's the HTTP at the start of the URL. 17 00:01:00,935 --> 00:01:05,202 Localhost:3000 is the host and the port. 18 00:01:05,202 --> 00:01:09,660 And /posts at the end is the path of the resource you want. 19 00:01:09,660 --> 00:01:11,560 When you press enter to load the URL, 20 00:01:11,560 --> 00:01:16,210 your browser sends an HTTP get request, it gets the page. 21 00:01:16,210 --> 00:01:19,620 There are other HTTP requests types like post and 22 00:01:19,620 --> 00:01:22,290 delete too, we'll look at those later. 23 00:01:22,290 --> 00:01:27,480 If you'd like to learn more about the HTTP protocol, just check the teacher's notes. 24 00:01:27,480 --> 00:01:30,010 If we switch to the terminal and look in the log, 25 00:01:30,010 --> 00:01:33,240 we can see where Rails receives the request and how it was handled. 26 00:01:33,240 --> 00:01:37,049 [SOUND] This log shows where Rails received the request, 27 00:01:37,049 --> 00:01:41,925 passed it to a controller, loaded some model data and rendered a view. 28 00:01:41,925 --> 00:01:45,380 Over the next few videos, we'll look at each of these components. 29 00:01:45,380 --> 00:01:47,440 Right now we just want to give you an overview. 30 00:01:47,440 --> 00:01:49,790 So don't worry about remembering every detail you see.