1
00:00:00,720 --> 00:00:01,620
Hello and welcome.

2
00:00:01,620 --> 00:00:13,050
In this lecture we are going to create the Schule action and also show you in the last lecture we were

3
00:00:13,110 --> 00:00:16,620
able to see to the quantrell there.

4
00:00:17,100 --> 00:00:25,960
But when we submitted it because once you said you have to redirect and we redirected it to the show.

5
00:00:26,190 --> 00:00:30,820
We haven't actually got any templates yet or action for this show.

6
00:00:30,890 --> 00:00:32,190
We're getting this error.

7
00:00:32,460 --> 00:00:40,620
So we need to go into the post quantrell an add a shill action and also create a corresponding template

8
00:00:40,680 --> 00:00:43,780
of view for that.

9
00:00:43,780 --> 00:00:51,420
In the last lecture we also created a private method which we call post on the score programs which

10
00:00:51,480 --> 00:00:59,160
includes all these fields that are required for the forms or we say we return the form what have a title

11
00:00:59,190 --> 00:01:00,060
and a body.

12
00:01:00,270 --> 00:01:05,690
So we don't permit me this that the two columns that are allowed.

13
00:01:05,760 --> 00:01:17,530
We then use this the name of this action here we passed it in here has a value for this post dot new.

14
00:01:17,940 --> 00:01:28,980
So let's go up here and we're just going to create the show action just after the new a good practice

15
00:01:29,190 --> 00:01:38,160
practice that is commonly applied for standard cried actions krudd Meaning create read or date and delete

16
00:01:38,760 --> 00:01:39,900
these two.

17
00:01:39,960 --> 00:01:47,790
Basically you could place each of the actions in each controller in the following order so you have

18
00:01:47,790 --> 00:01:54,820
the index which we've already got and after the index is done have you then have to do a show.

19
00:01:55,110 --> 00:01:57,110
So the show have to go into somewhere then.

20
00:01:57,120 --> 00:02:05,450
Then after the show you get new and then we added edit create opt out and delete or destroy.

21
00:02:05,760 --> 00:02:11,400
So the issue has to come on than the the index.

22
00:02:11,400 --> 00:02:24,120
This is woven we're at it so I'm just going to type in the air show in lower case and then and before

23
00:02:24,120 --> 00:02:27,960
I add any variables to this show I change soon.

24
00:02:28,030 --> 00:02:38,520
I just want to quickly run the racz command so that I can just highlight something to look to been slashed

25
00:02:40,470 --> 00:02:51,530
rails grout and those shows or the client raoult we have so we can see here from all the routes we have.

26
00:02:51,660 --> 00:02:59,640
We can see the one for this show here so you can see where the post is the action if they get where

27
00:02:59,720 --> 00:03:04,960
you run the post requires an eye here and you've got the format.

28
00:03:04,980 --> 00:03:15,120
It also requires action cords show in the post controller so the syntax the actual hadeed it tells the

29
00:03:15,120 --> 00:03:21,090
reals that this route expects an I.D. parameter.

30
00:03:21,480 --> 00:03:27,600
Okay which is in our case will be the idea of the post.

31
00:03:27,600 --> 00:03:32,330
So now that we've got that out of the way I just wanted to see that less.

32
00:03:32,340 --> 00:03:35,370
Now add it in to this show action.

33
00:03:35,700 --> 00:03:42,130
So the way we did it we had before had the variable pulse.

34
00:03:42,510 --> 00:03:51,210
And when I said that to you of course to post model this is the model because you can see the upper

35
00:03:51,210 --> 00:03:54,330
case P indicates that is a class.

36
00:03:54,410 --> 00:04:01,730
You don't find and don't pass it.

37
00:04:02,280 --> 00:04:03,370
The ramps

38
00:04:05,970 --> 00:04:10,870
and inside the paradigms we pass him the idea.

39
00:04:11,190 --> 00:04:20,550
So when the post is posted or when the funds are submitted it should have an A D to identify that post

40
00:04:21,080 --> 00:04:23,880
will put the Aidy there.

41
00:04:23,880 --> 00:04:26,870
So let me just explain this line here.

42
00:04:26,880 --> 00:04:28,150
What I have done here.

43
00:04:28,290 --> 00:04:37,080
So we amusingly post doc find to find the post that we will be interested in.

44
00:04:37,090 --> 00:04:47,310
As any post that's been submitted we use in the post of find to find the post and were passing in the

45
00:04:47,320 --> 00:04:54,370
programs I took So to get the idea parameter from the request.

46
00:04:54,570 --> 00:04:59,800
So when the form finally of me to one I get the idea from that submission.

47
00:05:00,180 --> 00:05:09,950
And pass it on to the value of the paramus saw and also have used an instance of the variable which

48
00:05:09,950 --> 00:05:12,580
is prefixed with the at symbol.

49
00:05:12,620 --> 00:05:21,610
This is an instance of the pulse variable saw using that to hold or store a reference to the article.

50
00:05:21,620 --> 00:05:23,540
Sorry to the post object.

51
00:05:23,750 --> 00:05:32,330
So my using that to store a reference to the post object.

52
00:05:32,760 --> 00:05:40,840
The reason we have to do this is that rails will pass all instance variables to the view.

53
00:05:41,120 --> 00:05:50,810
Okay so it's important that we are able to bring friends an instance or hold an instance of that post

54
00:05:50,900 --> 00:05:52,480
object.

55
00:05:53,240 --> 00:06:00,800
Okay so now that we've got the issue access or do we have to create a corresponding view so to do that

56
00:06:00,800 --> 00:06:03,540
we go to the use.

57
00:06:03,860 --> 00:06:08,390
So caught up fully views this is a views we go to post.

58
00:06:08,390 --> 00:06:09,830
We've already got two views in there.

59
00:06:09,830 --> 00:06:18,770
Right click on post and click new 0 2 file save us.

60
00:06:19,080 --> 00:06:21,500
I am going to call this show

61
00:06:24,370 --> 00:06:37,700
dot his t m l p r b r b stands for embedded Ruby C so inside the new template view we need to add some

62
00:06:37,700 --> 00:06:38,400
tags.

63
00:06:38,430 --> 00:06:46,650
That's going to start with his team multipack some and I hate to tag here and our just inside them go

64
00:06:46,670 --> 00:06:54,650
to embed Ruby So this is the embedded Ruby and you do that with a percent sign good set.

65
00:06:54,660 --> 00:06:56,430
Give it the value equals two.

66
00:06:56,440 --> 00:07:03,440
I'm going to sell it to the post under Title

67
00:07:06,130 --> 00:07:14,680
K and then I'll close that close that tank and also close the Hakes to tack.

68
00:07:14,820 --> 00:07:25,160
Mean create a paragraph to the p tag to create a paragraph again and when I'm in bed Ruby site is sent.

69
00:07:25,310 --> 00:07:33,730
It was too big to send that to the post dog body.

70
00:07:34,100 --> 00:07:35,300
Okay.

71
00:07:36,080 --> 00:07:41,650
Close that and then close the tag.

72
00:07:41,650 --> 00:07:51,530
The HTP tag then are saved that saw when the form is sound when you submit it is sure the title and

73
00:07:51,860 --> 00:07:52,780
the body.

74
00:07:53,150 --> 00:08:00,210
So now that we've got the action sorted now we've also got the show template sorted.

75
00:08:00,240 --> 00:08:04,800
We should be able to post something and see what we've posted.

76
00:08:04,820 --> 00:08:10,880
So let's let me refresh the form refresh this.

77
00:08:11,660 --> 00:08:14,760
Okay this is a previous post you can see is now showing.

78
00:08:14,750 --> 00:08:16,070
Not so if I want to.

79
00:08:16,070 --> 00:08:18,700
You can see this is the idea I was talking about.

80
00:08:18,710 --> 00:08:20,600
This is the idea of the post.

81
00:08:20,990 --> 00:08:31,510
So let me just amend that and typing new knew that we can add another post just to see it working right

82
00:08:31,520 --> 00:08:31,810
side.

83
00:08:31,810 --> 00:08:32,810
Just say

84
00:08:36,350 --> 00:08:37,850
hey.

85
00:08:42,860 --> 00:08:47,670
Thanks for watching.

86
00:08:47,980 --> 00:08:52,550
I said this it will pause and redirect to the show.

87
00:08:54,510 --> 00:08:54,970
Okay.

88
00:08:54,990 --> 00:08:58,980
Now you can see there this is the actual issue here.

89
00:08:59,010 --> 00:09:00,680
So their vows sent.

90
00:09:00,690 --> 00:09:05,250
I've just submitted it redirects to the view.

91
00:09:05,270 --> 00:09:08,210
You can see this is the idea of the portrait.

92
00:09:08,220 --> 00:09:10,320
This is post number three.

93
00:09:10,590 --> 00:09:15,330
So at the moment there is no way of listing everything we've posted.

94
00:09:15,570 --> 00:09:21,780
So in the next lecture we are going to sort that out so everything that gets posted can be listed on

95
00:09:21,780 --> 00:09:22,860
the page.

96
00:09:22,860 --> 00:09:24,200
Thanks for watching.
