Hell you are welcome in this show.
We are going to split the views from the show template to show a template.
It's a big crowd.
So I'm going to split the viewers from there and create two separate views within the comments directly.
So this is what our show template looks like at the moment which is this should dot hastier mailed.
He.
B.
So what I want to do I want to separate the leave forms and this area here.
I've added for the comments.
So if we look at the view here the view area here we've got these are all the views belonging to the
post and we're using this show view which belong so they post what I want to do is create really fight
expand this comments directly.
There is no views here.
I want to create a couple that we can transfer these.
Were going to split this into two separate.
He is.
So to begin I'm just going to right click on the comments falder and click on new file.
I'm going to do file save those.
I'm going to call this.
I'm going to make it a partial file and call it on the score.
Comments.
But here is t e mail.
E r b.
So a partial files have on the score be prefixed before the name of your father.
I'm going to save this parshall's basically partial files allow you to easily organize and reuse your
view with the code.
In your view scanner allows you to easily organize and you really use it for any of your Real's application.
Partial file mainly typically have an on the score at the beginning and you also named them the same
way you name your files so as the dot his TMF dot E R B.
So one going to do.
Now I'm going to go to the show template here and I would just grab this.
So I'm just going to grab this.
Right click cut and go to the comments underscore comments and paste that in there just one as saved
that matches or saved.
Okay so we've got some space in here now.
Next thing I want to do is create on Mother template and when I go back in to the comments you hear
right click and go new do file same vows.
This also is going to be a partial.
I am going to do on this core form.
DOT.
Hey T email dot E R B.
And I'm going to say that I'm going to go to the show and win and grab all this.
I cut and pasted in there.
And click save.
So you can see the show.
Sure.
For you now is looking a bit tidier just like we have a link to delete post.
I want there to be a link to delete the comments so I go back to the comments area here.
I'm just going to paste in and does a tab and just paste team the code here.
So this is what we're going to use to remove any comments or this is a link.
So set in a link here and a text just put here is remove comma.
You can put whatever text you like you can put delete or whatever just put rim of comment and here past
team the variables so a bit comment.
Don't post the poser blunt to the comment and or saw the actual comment as would be the variable.
The inside be a read here and then we have a method.
The method is going to be delete and we are going to have a confirmation so that if you want to delete
a comment you will be prompted and ask.
Do you really really really want to.
So why need to do so get rid of this p tag here.
Let's close in one here and make this the closing P tag.
Does the opening.
And this would be the closing so one going to do is remove this div.
Here I am.
So that it ends here right does begin indeed.
And that's the end indeed.
And that's the clause in paragraph.
That's the opening paragraph tag.
So I'm going to also remove fits here because we've got an end in tag there so there is no conflict
so I'll save this.
What this would do it will create a link in our comment.
How Give was an option to delete if we want to.
So let's go to the form side of things and try and fix this one as.
O.
K..
This looks o k.
Can't see anything to change it.
It looks fine.
Just going to see that but we need to make a reference to them inside our show template.
We need to find a way of rendering this two forms because our parshall's we go in.
There's a way we can add it and it will be rendered from within the shawl template.
Here to save time.
I'm just going to add the path here.
So when this is all we need in order to render because our partial farr's we don't need to specify the
full path so we just typee.
We just use a render in order to render the forms sorted timid or a B and the comments.
Okay just read this two line of code here.
Does should render it fun of the thing we need to do is add a action inside a commons controller that
would enable laws to delete the comments at the moment.
We can't delete any comments if we try I will get an error cos we've not added the action to do that
to save time.
I am going to go to the kamens controller.
I have already written out the code I'm just going to paste in just to save time.
The process is identical to what we've been doing so find during the course.
So you should be familiar with it by now hopefully pasting.
Read this try method here.
So basically this is the method to enable you to delete any comment.
So here this we describe here we did def and move the pause variable we said that 2 did post a variable
in the model.
This this is from the Post's model.
And again it will look for the post a d to.
That would be the reference to comment on and here require the comment variable we set in that too that
puts a variable dot comments out of find again the we use in the idea.
From that comment and then to Destro we need to call the district action or method.
We do that usedn't is variable.
Comments don't destroy.
Once a comment has been destroyed we need to redirect the user to this path here which is post on this
core path PPO's was.
Message is be read destroyed or delete it.
He gets redirected.
So I click C and that should be it.
So now let's try and do it.
Go back to our form.
Hopefully everything's gone right.
I'll just refresh.
Make sure there's no errors.
I'm just going to add it teschke comment here are just see.
Tester.
No C.
Just
testing.
And I'll quote the comment.
All right.
So I'm not going to comment now.
So See this link here to read more comment.
Remote saying Do you really want to see excelon So the comment the delete is working correctly as design.
So that's it for this lecture.
We have implemented the delete option so we are able to create comments.
We are also able to delete comments.
Thankyou so much for watching in the next link.
Sure we are going to implement some security.
Of course we don't want anyone to just be able to answer comments and do our kind of stuff on our blog.
I will implement on basic security.
Thanks for watching and bye for now.