1 00:00:00,670 --> 00:00:08,550 Hello one Welcome to this lecture in this lecture we are going to generate any comments controller to 2 00:00:08,560 --> 00:00:17,260 match the model we've already generated sule open or pure terminal or your command line. 3 00:00:17,280 --> 00:00:20,590 Or if you're using good bass he could open it up. 4 00:00:20,630 --> 00:00:21,840 And what we want to do. 5 00:00:21,840 --> 00:00:25,870 Make sure you also in your correct Derek creep for the project. 6 00:00:26,260 --> 00:00:31,110 So we're going to generate the controller listen we we generated the pulse controller. 7 00:00:31,140 --> 00:00:38,360 So for window we're just going to type in been followed by the word Real's. 8 00:00:40,470 --> 00:00:43,660 Space followed by the word generate. 9 00:00:43,680 --> 00:00:45,630 You can just type in G if you want. 10 00:00:45,630 --> 00:00:47,040 That should work. 11 00:00:47,280 --> 00:00:50,100 I like to write a few words. 12 00:00:50,100 --> 00:00:51,890 I was going to generate. 13 00:00:52,750 --> 00:01:01,660 And then this space followed by You need to specify what you're going to generate and AC controller. 14 00:01:04,220 --> 00:01:07,390 Control our space. 15 00:01:07,490 --> 00:01:21,300 I am going to give the controller in name and one of colleague comments by case c c o m m e e n t s. 16 00:01:21,740 --> 00:01:28,950 So thus the name on my controller and then press enter and that should generate the files for the control. 17 00:01:29,270 --> 00:01:36,180 So these are the files created by the Generate controller. 18 00:01:37,050 --> 00:01:37,830 Comment here. 19 00:01:37,830 --> 00:01:39,320 This Deadmen we just ran here. 20 00:01:39,330 --> 00:01:47,310 The command when ran generated these files here so I'll just run through a few and then will look at 21 00:01:47,310 --> 00:01:55,030 the app control ask comments controller the app controller that one there that I'd be. 22 00:01:55,050 --> 00:01:58,080 This is the comments controller. 23 00:01:58,080 --> 00:02:02,310 Then if we go to perhaps you comments. 24 00:02:02,460 --> 00:02:03,880 Got this one here. 25 00:02:04,110 --> 00:02:07,190 This here the views on the controller. 26 00:02:07,200 --> 00:02:10,180 This is where the views of the controller are stored. 27 00:02:10,210 --> 00:02:15,310 Any views you have full control will be stored here. 28 00:02:15,660 --> 00:02:22,470 We're not doing any test soon but if we're where this is where we reference the files for testing this 29 00:02:22,740 --> 00:02:24,420 would be the test for the controller. 30 00:02:24,420 --> 00:02:30,320 If we were to do test and in here we've got be helper. 31 00:02:30,460 --> 00:02:33,950 Since you help pa file in a folder for you. 32 00:02:34,290 --> 00:02:37,150 Then we've got a coffee script far here. 33 00:02:37,150 --> 00:02:45,090 If we were using coffee script and then leaves us on files for here says in is we have cascading style 34 00:02:45,090 --> 00:02:49,170 sheet we want to apply for the controller. 35 00:02:50,320 --> 00:02:53,550 The way comments are truly work is sad. 36 00:02:53,860 --> 00:03:01,230 Normally someone would like to leave comments directly after they've read. 37 00:03:01,260 --> 00:03:03,610 I read a post or read a blog. 38 00:03:03,790 --> 00:03:08,440 So we want to read leave comments in or underneath that. 39 00:03:08,440 --> 00:03:16,270 And we also want to implement in such a way that was they added the comment and then they get redirected 40 00:03:16,270 --> 00:03:25,000 back to the post show page so that they can see the comment list it only to do what we need to open 41 00:03:25,000 --> 00:03:31,560 on the our post show template. 42 00:03:31,600 --> 00:03:32,120 Why. 43 00:03:32,170 --> 00:03:32,610 Why. 44 00:03:32,620 --> 00:03:35,830 Why do some wiring up there. 45 00:03:35,830 --> 00:03:40,230 So let's go to our show Post Schule template. 46 00:03:40,510 --> 00:03:43,080 So these our views quickly can post. 47 00:03:43,110 --> 00:03:44,420 We click on Sure. 48 00:03:44,440 --> 00:03:49,430 So this is where we are going to implement the comment. 49 00:03:49,740 --> 00:03:57,430 Ideally would like to add a form here that when they tell people to add a comment. 50 00:03:58,270 --> 00:04:03,640 So while I want to do is put an underline here some do that with a hey chart tag. 51 00:04:03,820 --> 00:04:11,950 Typing they tag h.r. unbathed we just put a horizontal line on that page. 52 00:04:12,190 --> 00:04:17,580 And next I want to add a tag here should three head in tag. 53 00:04:18,510 --> 00:04:22,620 And for the comment ah just see had. 54 00:04:24,710 --> 00:04:25,810 Comment. 55 00:04:28,460 --> 00:04:29,990 And I'll close the tag. 56 00:04:31,900 --> 00:04:33,080 So one good to do. 57 00:04:33,100 --> 00:04:34,000 I'm here. 58 00:04:34,000 --> 00:04:37,020 I'm going to add form. 59 00:04:37,050 --> 00:04:43,640 So these this way to do I'm going to go to one of my other forms kind of good to edit heat here may 60 00:04:44,080 --> 00:04:44,450 be. 61 00:04:44,470 --> 00:04:51,000 I'm just going to grab the form and make some changes. 62 00:04:51,310 --> 00:05:01,240 I just grab all that copy and I'll go to my show edit and just paste it and then make some changes to 63 00:05:01,240 --> 00:05:01,980 it. 64 00:05:02,440 --> 00:05:04,230 So I'm just gonna delete this bit. 65 00:05:04,230 --> 00:05:05,380 This error handling. 66 00:05:05,410 --> 00:05:09,990 I don't need that and I'm just going to add another line here. 67 00:05:10,240 --> 00:05:20,020 So I made some modifications to the form that will be used to the comments so this is the form here. 68 00:05:20,500 --> 00:05:30,610 So here we've got the history tag to the comment and then we've got the the embedded Ruby here and we've 69 00:05:30,640 --> 00:05:41,590 got the you the form help pas that we've used here to create the form and we've got the post variable. 70 00:05:41,950 --> 00:05:46,030 We saw passing passing they posed Dort comments. 71 00:05:46,120 --> 00:05:49,060 And this is similar to the previous forms we did. 72 00:05:49,060 --> 00:05:56,890 Again we use in that here to grid the labels whatever name you set when you created the model for the 73 00:05:56,890 --> 00:05:57,390 comments. 74 00:05:57,390 --> 00:05:58,960 Does the values you entail. 75 00:05:59,050 --> 00:06:06,550 I entered the value for name and body size or whatever detail you give in for that is what you have 76 00:06:06,550 --> 00:06:08,760 to input here as well. 77 00:06:08,890 --> 00:06:15,670 And is a standard just these are classes bootstrap classes bootstrap classes and so on. 78 00:06:15,670 --> 00:06:25,000 So just make sure your form is exactly the way I have set mine up there and tried to make sure or the 79 00:06:25,750 --> 00:06:30,330 tags match up or the plane unclose intact make sure they are match. 80 00:06:30,460 --> 00:06:36,190 And the ones you don't just click on see if there's any thing missing. 81 00:06:36,190 --> 00:06:40,520 The form will not display you will get an error on the blog page. 82 00:06:40,710 --> 00:06:43,970 But if everything works out you should get a page like this. 83 00:06:43,990 --> 00:06:51,850 So this is now a page that you can use to add a comment flag go to the home page again and click Go 84 00:06:51,850 --> 00:06:53,120 to post. 85 00:06:53,170 --> 00:06:55,620 You should get me from here. 86 00:06:55,630 --> 00:06:59,160 That will enable you to add your comment. 87 00:06:59,380 --> 00:07:02,160 So that's it for this Late Show in the next lecture. 88 00:07:02,180 --> 00:07:07,860 We are going to add some actions to our comments controller. 89 00:07:08,200 --> 00:07:09,320 Thanks for watching. 90 00:07:09,430 --> 00:07:10,540 And by phone now.