Hello and welcome.
In this lecture we are going to implement deleting post.
So far we've been able to create pause.
We care an update post and we can edit the post.
So the final krudd operation is deleting a post.
So this is what our blog look like at the moment.
So are we going to implement any way to delete the post.
We no longer require so good to have to go to our post controller and add a function that will remove
or destroy the post.
So let's come down here in just under the update.
We're going to add a destroy action C D E F space this Troy.
That's the name of the action that gets rid of the post you don't need and don't typing it.
And in between there.
I'm going to copy this here.
I will just change one or two things there and do paste.
The reason I'm keeping the because you don't need the idea to every post will have a unique idea.
So you want to make sure you are actually deleting the exact post.
We need to also core though.
Destroy actions so that we will call that we do at.
The variable.
Post.
Don't destroy.
So that will cause the action to destroy or delete the post.
We also want to redirect once the post has been deleted.
So we user redirect
underscore to.
Post.
On the score path.
Notice the pleuro there is post and not post.
So click to save big changes mess we need to add in link to delete.
So if we go to our show for you here this show of you one going to do.
I'm just going to copy this pasted on the anxious change.
Just change a few things here.
Some one change this here from head it to see delete an A more so going to change the bottom class from
bot in default temperton Danger.
KING The button then jabez's gleave makes the button read gives it a red colour.
And here for the part I'm going to change is from edit to post.
We'll just get rid of the extra.
Yeah.
Dorsey post on the score path and they were passing the post variable.
We going to have to define his method that we're going to use to implement his delete so on the turn
of pause from just gone a tab down and then indent this habit I am just going to tamp down a little
bit here.
I'm going to add a method.
This is going to be the method you're going to use to perform the delete and then here call on again.
Type in the word delete a comma.
And when we delete it I also want there to be a prompt to actually use.
Are you sure you want to delete.
So we need to method here we're going to put data to represent the model and then in between.
Here is where I will add the message we want to display when Dad tried to delete it.
So in between the kernel embrace this we're just going to type pain.
Confirm this is it.
The Javascript part of paint so it will prompt them for a message to confirm and then would type in
the message each and see.
Do you really you can type whether you won by the way.
Do you really want to.
Do this.
And then we need to put a karma here to indicate that we have finished.
So we just get rid of this extra curly braces and save that and that should be okay.
So let's test this out.
So let's open our bubb blog refresh to make sure there are no errors.
See example I want to delete this post and go to the post.
And thus my delete button actually delete.
You see I get the message.
This is a damaske group side thinks this is.
Do you really want to do this.
I say okay and it deletes the post.
So now I've only got 2 left.
I want to do the same.
Delete that one I click delete.
Yep and then goes back so I've only got the one put.
So we've successfully implemented the delete operation in the crowd.
So we've got create a bit.
We're able to create way able to read.
We're able to update we're able to delete.
Those are the four operations you perform with a crowd.
So just sit for the cross sign things in the next lecture.
We aren't going to try and implement it we need to add comments to our post.
Thanks for watching and bye for now.