1
00:00:00,650 --> 00:00:01,540
Hello and welcome.

2
00:00:01,550 --> 00:00:06,580
In this lecture we are going to implement deleting post.

3
00:00:06,770 --> 00:00:10,540
So far we've been able to create pause.

4
00:00:10,650 --> 00:00:15,990
We care an update post and we can edit the post.

5
00:00:16,160 --> 00:00:22,430
So the final krudd operation is deleting a post.

6
00:00:22,640 --> 00:00:26,210
So this is what our blog look like at the moment.

7
00:00:26,210 --> 00:00:31,800
So are we going to implement any way to delete the post.

8
00:00:31,820 --> 00:00:43,520
We no longer require so good to have to go to our post controller and add a function that will remove

9
00:00:43,640 --> 00:00:45,370
or destroy the post.

10
00:00:45,580 --> 00:00:50,950
So let's come down here in just under the update.

11
00:00:50,960 --> 00:00:59,890
We're going to add a destroy action C D E F space this Troy.

12
00:00:59,990 --> 00:01:07,140
That's the name of the action that gets rid of the post you don't need and don't typing it.

13
00:01:07,470 --> 00:01:08,800
And in between there.

14
00:01:08,820 --> 00:01:13,580
I'm going to copy this here.

15
00:01:13,730 --> 00:01:19,630
I will just change one or two things there and do paste.

16
00:01:19,640 --> 00:01:25,370
The reason I'm keeping the because you don't need the idea to every post will have a unique idea.

17
00:01:25,460 --> 00:01:31,180
So you want to make sure you are actually deleting the exact post.

18
00:01:31,790 --> 00:01:34,400
We need to also core though.

19
00:01:34,410 --> 00:01:40,260
Destroy actions so that we will call that we do at.

20
00:01:41,320 --> 00:01:41,930
The variable.

21
00:01:41,930 --> 00:01:45,060
Post.

22
00:01:45,670 --> 00:01:47,780
Don't destroy.

23
00:01:48,410 --> 00:01:55,970
So that will cause the action to destroy or delete the post.

24
00:01:56,000 --> 00:02:01,850
We also want to redirect once the post has been deleted.

25
00:02:02,210 --> 00:02:04,420
So we user redirect

26
00:02:06,750 --> 00:02:09,670
underscore to.

27
00:02:12,000 --> 00:02:13,460
Post.

28
00:02:15,040 --> 00:02:17,600
On the score path.

29
00:02:17,680 --> 00:02:22,060
Notice the pleuro there is post and not post.

30
00:02:23,900 --> 00:02:32,480
So click to save big changes mess we need to add in link to delete.

31
00:02:32,480 --> 00:02:37,940
So if we go to our show for you here this show of you one going to do.

32
00:02:37,950 --> 00:02:45,740
I'm just going to copy this pasted on the anxious change.

33
00:02:46,430 --> 00:02:48,180
Just change a few things here.

34
00:02:49,870 --> 00:02:59,910
Some one change this here from head it to see delete an A more so going to change the bottom class from

35
00:02:59,910 --> 00:03:02,920
bot in default temperton Danger.

36
00:03:05,550 --> 00:03:13,340
KING The button then jabez's gleave makes the button read gives it a red colour.

37
00:03:14,400 --> 00:03:22,870
And here for the part I'm going to change is from edit to post.

38
00:03:22,900 --> 00:03:25,590
We'll just get rid of the extra.

39
00:03:26,130 --> 00:03:26,600
Yeah.

40
00:03:26,610 --> 00:03:32,850
Dorsey post on the score path and they were passing the post variable.

41
00:03:32,940 --> 00:03:40,850
We going to have to define his method that we're going to use to implement his delete so on the turn

42
00:03:40,860 --> 00:03:51,390
of pause from just gone a tab down and then indent this habit I am just going to tamp down a little

43
00:03:51,390 --> 00:03:54,420
bit here.

44
00:03:54,430 --> 00:03:57,490
I'm going to add a method.

45
00:03:58,350 --> 00:04:05,750
This is going to be the method you're going to use to perform the delete and then here call on again.

46
00:04:05,750 --> 00:04:09,670
Type in the word delete a comma.

47
00:04:10,740 --> 00:04:15,690
And when we delete it I also want there to be a prompt to actually use.

48
00:04:15,690 --> 00:04:18,580
Are you sure you want to delete.

49
00:04:18,600 --> 00:04:27,390
So we need to method here we're going to put data to represent the model and then in between.

50
00:04:27,390 --> 00:04:35,320
Here is where I will add the message we want to display when Dad tried to delete it.

51
00:04:35,700 --> 00:04:41,530
So in between the kernel embrace this we're just going to type pain.

52
00:04:41,540 --> 00:04:45,010
Confirm this is it.

53
00:04:46,710 --> 00:04:51,870
The Javascript part of paint so it will prompt them for a message to confirm and then would type in

54
00:04:51,870 --> 00:04:55,040
the message each and see.

55
00:04:58,240 --> 00:05:05,280
Do you really you can type whether you won by the way.

56
00:05:05,280 --> 00:05:09,950
Do you really want to.

57
00:05:12,610 --> 00:05:14,300
Do this.

58
00:05:17,960 --> 00:05:24,470
And then we need to put a karma here to indicate that we have finished.

59
00:05:25,610 --> 00:05:34,710
So we just get rid of this extra curly braces and save that and that should be okay.

60
00:05:34,730 --> 00:05:37,630
So let's test this out.

61
00:05:38,150 --> 00:05:44,090
So let's open our bubb blog refresh to make sure there are no errors.

62
00:05:44,090 --> 00:05:48,140
See example I want to delete this post and go to the post.

63
00:05:48,530 --> 00:05:51,640
And thus my delete button actually delete.

64
00:05:51,680 --> 00:05:52,790
You see I get the message.

65
00:05:52,790 --> 00:05:55,640
This is a damaske group side thinks this is.

66
00:05:55,640 --> 00:05:57,520
Do you really want to do this.

67
00:05:57,700 --> 00:06:00,330
I say okay and it deletes the post.

68
00:06:00,410 --> 00:06:02,610
So now I've only got 2 left.

69
00:06:02,660 --> 00:06:04,370
I want to do the same.

70
00:06:04,460 --> 00:06:07,910
Delete that one I click delete.

71
00:06:08,360 --> 00:06:13,130
Yep and then goes back so I've only got the one put.

72
00:06:13,160 --> 00:06:19,780
So we've successfully implemented the delete operation in the crowd.

73
00:06:19,970 --> 00:06:22,400
So we've got create a bit.

74
00:06:22,410 --> 00:06:24,970
We're able to create way able to read.

75
00:06:25,040 --> 00:06:27,550
We're able to update we're able to delete.

76
00:06:27,560 --> 00:06:33,150
Those are the four operations you perform with a crowd.

77
00:06:33,500 --> 00:06:38,390
So just sit for the cross sign things in the next lecture.

78
00:06:38,630 --> 00:06:46,120
We aren't going to try and implement it we need to add comments to our post.

79
00:06:46,130 --> 00:06:48,390
Thanks for watching and bye for now.
