Hello one Welcome to this lecture in this lecture we are going to generate any comments controller to
match the model we've already generated sule open or pure terminal or your command line.
Or if you're using good bass he could open it up.
And what we want to do.
Make sure you also in your correct Derek creep for the project.
So we're going to generate the controller listen we we generated the pulse controller.
So for window we're just going to type in been followed by the word Real's.
Space followed by the word generate.
You can just type in G if you want.
That should work.
I like to write a few words.
I was going to generate.
And then this space followed by You need to specify what you're going to generate and AC controller.
Control our space.
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.
So thus the name on my controller and then press enter and that should generate the files for the control.
So these are the files created by the Generate controller.
Comment here.
This Deadmen we just ran here.
The command when ran generated these files here so I'll just run through a few and then will look at
the app control ask comments controller the app controller that one there that I'd be.
This is the comments controller.
Then if we go to perhaps you comments.
Got this one here.
This here the views on the controller.
This is where the views of the controller are stored.
Any views you have full control will be stored here.
We're not doing any test soon but if we're where this is where we reference the files for testing this
would be the test for the controller.
If we were to do test and in here we've got be helper.
Since you help pa file in a folder for you.
Then we've got a coffee script far here.
If we were using coffee script and then leaves us on files for here says in is we have cascading style
sheet we want to apply for the controller.
The way comments are truly work is sad.
Normally someone would like to leave comments directly after they've read.
I read a post or read a blog.
So we want to read leave comments in or underneath that.
And we also want to implement in such a way that was they added the comment and then they get redirected
back to the post show page so that they can see the comment list it only to do what we need to open
on the our post show template.
Why.
Why do some wiring up there.
So let's go to our show Post Schule template.
So these our views quickly can post.
We click on Sure.
So this is where we are going to implement the comment.
Ideally would like to add a form here that when they tell people to add a comment.
So while I want to do is put an underline here some do that with a hey chart tag.
Typing they tag h.r. unbathed we just put a horizontal line on that page.
And next I want to add a tag here should three head in tag.
And for the comment ah just see had.
Comment.
And I'll close the tag.
So one good to do.
I'm here.
I'm going to add form.
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
be.
I'm just going to grab the form and make some changes.
I just grab all that copy and I'll go to my show edit and just paste it and then make some changes to
it.
So I'm just gonna delete this bit.
This error handling.
I don't need that and I'm just going to add another line here.
So I made some modifications to the form that will be used to the comments so this is the form here.
So here we've got the history tag to the comment and then we've got the the embedded Ruby here and we've
got the you the form help pas that we've used here to create the form and we've got the post variable.
We saw passing passing they posed Dort comments.
And this is similar to the previous forms we did.
Again we use in that here to grid the labels whatever name you set when you created the model for the
comments.
Does the values you entail.
I entered the value for name and body size or whatever detail you give in for that is what you have
to input here as well.
And is a standard just these are classes bootstrap classes bootstrap classes and so on.
So just make sure your form is exactly the way I have set mine up there and tried to make sure or the
tags match up or the plane unclose intact make sure they are match.
And the ones you don't just click on see if there's any thing missing.
The form will not display you will get an error on the blog page.
But if everything works out you should get a page like this.
So this is now a page that you can use to add a comment flag go to the home page again and click Go
to post.
You should get me from here.
That will enable you to add your comment.
So that's it for this Late Show in the next lecture.
We are going to add some actions to our comments controller.
Thanks for watching.
And by phone now.