1 00:00:00,720 --> 00:00:02,170 Hello and welcome. 2 00:00:02,220 --> 00:00:13,000 In this lecture we are going to declare or create a resul what is a resource in Ruby on Rails a resource. 3 00:00:13,010 --> 00:00:23,520 He is referred to his collection of simular objects are glimmers could include post articles people 4 00:00:24,040 --> 00:00:29,330 animals can't eat fruits and so on. 5 00:00:29,370 --> 00:00:38,140 You can also create a crowd operation for Resource krudd basically stands for create. 6 00:00:38,340 --> 00:00:39,540 Read. 7 00:00:40,440 --> 00:00:48,640 Destroy destroy and delete the same thing so you can create a cross operation for a resource. 8 00:00:48,750 --> 00:00:54,870 So our web server is still running and that's how our page had the mom in the home page. 9 00:00:54,930 --> 00:01:04,020 We are going to need to create a few actions and also views for our post controller. 10 00:01:04,330 --> 00:01:14,970 So instead of doing the roots of the rats manually We are going to declare the post as a resource and 11 00:01:15,010 --> 00:01:22,260 the roads will be automatically generated from so when you create some power as a resource it generates 12 00:01:22,660 --> 00:01:25,740 defrantz for that resource. 13 00:01:25,770 --> 00:01:28,690 So let's open up our text editor. 14 00:01:29,160 --> 00:01:33,620 Expand the folder and then go to the trouts. 15 00:01:33,930 --> 00:01:38,160 So it would be on that config and then erupts. 16 00:01:38,290 --> 00:01:40,110 So inside is routs. 17 00:01:40,110 --> 00:01:47,300 Here we are going to clear the post as a resource. 18 00:01:47,580 --> 00:01:54,570 So just tab down and just all you need to do just type in the word resource. 19 00:01:59,730 --> 00:02:02,690 Okay resources. 20 00:02:03,170 --> 00:02:06,170 Yeah and then space. 21 00:02:08,860 --> 00:02:18,690 Call on and typing posts and that has now declared the post as a resource. 22 00:02:19,160 --> 00:02:27,640 So let's save the sit far click save or so now we've got the post as a response. 23 00:02:27,650 --> 00:02:34,840 By doing it this way that means we don't need to manually cruet the individual rollout's. 24 00:02:34,850 --> 00:02:42,140 So what I'm going to do now we are going to write and I'm going to write a command that would display 25 00:02:42,270 --> 00:02:51,030 all the rules by including the post as a resource here inside the Ralph's far to generate the routs 26 00:02:51,340 --> 00:02:54,580 the friend runs for the post. 27 00:02:54,620 --> 00:02:56,480 So let's see how that is done. 28 00:02:56,840 --> 00:03:01,000 So open up your terminal and leave the server running. 29 00:03:01,040 --> 00:03:02,320 Open up another terminal. 30 00:03:02,330 --> 00:03:09,440 Make sure you have navigated to your proved appropriate directory or your application directory. 31 00:03:09,530 --> 00:03:11,670 As I am you can see mine here. 32 00:03:11,990 --> 00:03:18,850 So what's in your project or application Derek create the command you need to type. 33 00:03:18,900 --> 00:03:32,600 Be n for if you on Windows machine slash don't type in the word Real's space reals will address space 34 00:03:32,910 --> 00:03:35,650 routs. 35 00:03:36,170 --> 00:03:41,610 If present up what this would do it was show or did define results. 36 00:03:41,660 --> 00:03:43,750 Press Enter. 37 00:03:43,790 --> 00:03:49,410 You see all the results generated so as you can see it has generated all the rules. 38 00:03:49,430 --> 00:03:58,490 This prevents us from doing it manually by declaring the post as a resource heater's generated for this 39 00:03:58,490 --> 00:04:02,360 rantz for us so you can see the index. 40 00:04:02,440 --> 00:04:12,150 You've got to create new eddied show or date and distrait which is also delete. 41 00:04:12,390 --> 00:04:19,230 So these are all the different control action for example for the post control. 42 00:04:19,570 --> 00:04:21,390 Kim performing create. 43 00:04:21,410 --> 00:04:27,400 When you create a new post then here of quote new again when you get the puts. 44 00:04:27,410 --> 00:04:35,390 So you've got the edit view on an edit to post and to show the PO's update and it is sure you can see 45 00:04:35,390 --> 00:04:37,360 there a different method here. 46 00:04:37,370 --> 00:04:45,740 He can see you've got to put the lead patch get all these different methods that are used for their 47 00:04:45,740 --> 00:04:49,240 outs so that's it for this lecture. 48 00:04:49,250 --> 00:05:00,080 In this make sure we declare the post as a resource an also ran the reals rollout's command to see or 49 00:05:00,110 --> 00:05:07,250 the defined rantz that we create it by declaring the post as a resource. 50 00:05:07,250 --> 00:05:09,210 Thanks for watching and bye for now.