1
00:00:00,780 --> 00:00:02,590
This is where we left.

2
00:00:02,610 --> 00:00:09,930
So what we are going to do is that we are going to fill up the imp with the data of the post.

3
00:00:10,140 --> 00:00:16,230
So let's get back to the update post template, which is this.

4
00:00:16,980 --> 00:00:24,860
And for each of the input field, I want to repopulate that using an attribute called value.

5
00:00:25,050 --> 00:00:33,810
And the value for this is equal to post dot title.

6
00:00:34,350 --> 00:00:37,020
So let's have a look if it's going to work.

7
00:00:38,400 --> 00:00:40,610
And we have the title here.

8
00:00:41,340 --> 00:00:46,410
Then for the description, we can also add the value here.

9
00:00:49,000 --> 00:00:50,740
Which is equal to this.

10
00:00:50,740 --> 00:00:55,300
So I can copy this one and.

11
00:00:55,970 --> 00:01:00,470
Pace, ETA and change to description.

12
00:01:02,280 --> 00:01:04,739
Likewise the select.

13
00:01:05,530 --> 00:01:09,610
The value equal to that.

14
00:01:12,170 --> 00:01:15,980
And this one is going to be category.

15
00:01:17,810 --> 00:01:18,710
Key.

16
00:01:19,620 --> 00:01:20,750
And that is it.

17
00:01:20,760 --> 00:01:23,610
So let's refresh it.

18
00:01:24,300 --> 00:01:26,930
Well, kind of find my conclusion.

19
00:01:26,940 --> 00:01:32,520
I think we are messing up with the eggs, So let me remove this one from here.

20
00:01:33,340 --> 00:01:37,150
And this one also from here.

21
00:01:37,990 --> 00:01:38,650
All right.

22
00:01:38,650 --> 00:01:49,930
But instead, I'm going to place it inside as that is, and equal to post dot description.

23
00:01:53,520 --> 00:01:56,080
All right, so let's see.

24
00:01:56,100 --> 00:01:57,090
Refresh it.

25
00:01:58,390 --> 00:02:00,850
And everything works fine.

26
00:02:01,150 --> 00:02:05,380
Let me update by adding 2 to 8 and category.

27
00:02:05,410 --> 00:02:06,190
Let's see.

28
00:02:07,330 --> 00:02:13,840
All fails are required, meaning that I'm trying to send without sending the image.

29
00:02:13,840 --> 00:02:16,150
So I think we can avoid that.

30
00:02:16,870 --> 00:02:23,320
So let's try to update using all the fields and let's see if it's going to work.

31
00:02:23,350 --> 00:02:24,940
Let me use this logo.

32
00:02:26,480 --> 00:02:29,900
And let me cross-check again.

33
00:02:31,440 --> 00:02:42,560
Well, it couldn't work simply because the endpoint for the form is not great, but instead is for update.

34
00:02:42,570 --> 00:02:45,870
So here we need to change this one to update.

35
00:02:45,900 --> 00:02:49,680
I'm going to be forward slash the ID of the post.

36
00:02:51,990 --> 00:03:00,540
A is equal to post dot underscore ID and we need to use the method override.

37
00:03:00,540 --> 00:03:03,690
So question mark underscore method.

38
00:03:04,930 --> 00:03:08,440
And is equal to put.

39
00:03:09,550 --> 00:03:10,240
All right.

40
00:03:10,240 --> 00:03:12,430
I think it should be fine.

41
00:03:13,430 --> 00:03:17,260
Okay, so let's go ahead and try again.

42
00:03:17,860 --> 00:03:20,410
EDIT Let me add two to it.

43
00:03:20,830 --> 00:03:27,220
This one and for the image, let me use any of these ones.

44
00:03:29,670 --> 00:03:31,470
A good success.

45
00:03:31,530 --> 00:03:32,830
So let's have a look.

46
00:03:32,850 --> 00:03:35,610
Let's go back to the home page and let's see.

47
00:03:36,490 --> 00:03:40,090
And I have the image being updated.

48
00:03:40,570 --> 00:03:48,110
But if we try to update without providing any of these fields, we are going to have an error.

49
00:03:48,130 --> 00:03:49,060
So let's see.

50
00:03:49,840 --> 00:03:55,930
And you can see that we got empty objects because we refused to provide the image.

51
00:03:56,170 --> 00:03:57,730
So we need to avoid that.

52
00:03:57,730 --> 00:04:03,880
But for the meantime, let's go ahead and then redirect after a success update, and we'll fix that

53
00:04:03,880 --> 00:04:05,620
one as we move on.

54
00:04:05,800 --> 00:04:11,710
So let's get back to the post and here we go inside the update.

55
00:04:13,480 --> 00:04:16,000
After updates we want to redirect.

56
00:04:16,000 --> 00:04:29,590
So here, in case an error, we are going to render rest return instead and restart, render and go

57
00:04:29,590 --> 00:04:34,090
to the post for a slash update post.

58
00:04:36,630 --> 00:04:40,600
I need to pass in the posts here empty.

59
00:04:40,600 --> 00:04:43,240
And then the error as that.

60
00:04:43,240 --> 00:04:48,460
And I will say you are not authorized to update this post.

61
00:04:48,460 --> 00:04:51,910
So we're going to be as you are not authorized.

62
00:04:52,570 --> 00:05:00,460
Remember, this one was used for the API development entirely by the front end like we did.

63
00:05:00,460 --> 00:05:01,840
We can hide a button.

64
00:05:02,170 --> 00:05:09,430
So let's continue to add this one as you are not authorized to update this post.

65
00:05:11,190 --> 00:05:11,850
Perfect.

66
00:05:11,850 --> 00:05:13,650
So let me copy this one.

67
00:05:14,490 --> 00:05:18,120
And inside the card block.

68
00:05:19,120 --> 00:05:24,670
And use the error from the DB or from the Sarah.

69
00:05:24,970 --> 00:05:31,470
And for success, I want to send a user to the home page or to the profile page.

70
00:05:31,480 --> 00:05:33,250
The choice is yours.

71
00:05:34,010 --> 00:05:34,980
Redirect.

72
00:05:35,290 --> 00:05:36,430
Red Dot.

73
00:05:36,430 --> 00:05:37,210
Redirect.

74
00:05:37,240 --> 00:05:39,250
Go to homepage for now.

75
00:05:39,820 --> 00:05:40,890
So let's see.

76
00:05:40,900 --> 00:05:43,690
So let me go to homepage.

77
00:05:44,290 --> 00:05:46,150
Click on this one.

78
00:05:48,870 --> 00:05:50,010
And.

79
00:05:51,020 --> 00:05:54,230
Update and then change this 1 to 3.

80
00:05:54,230 --> 00:05:55,190
And let's see.

81
00:05:56,540 --> 00:05:57,710
With our image.

82
00:05:58,940 --> 00:06:03,230
You can see that cannot read properly of undefined called path.

83
00:06:03,740 --> 00:06:05,000
That is the image.

84
00:06:05,000 --> 00:06:09,530
So we need to fix that one inside the controller in the next video.

