Hello and welcome.
In this lecture we are going to create the Schule action and also show you in the last lecture we were
able to see to the quantrell there.
But when we submitted it because once you said you have to redirect and we redirected it to the show.
We haven't actually got any templates yet or action for this show.
We're getting this error.
So we need to go into the post quantrell an add a shill action and also create a corresponding template
of view for that.
In the last lecture we also created a private method which we call post on the score programs which
includes all these fields that are required for the forms or we say we return the form what have a title
and a body.
So we don't permit me this that the two columns that are allowed.
We then use this the name of this action here we passed it in here has a value for this post dot new.
So let's go up here and we're just going to create the show action just after the new a good practice
practice that is commonly applied for standard cried actions krudd Meaning create read or date and delete
these two.
Basically you could place each of the actions in each controller in the following order so you have
the index which we've already got and after the index is done have you then have to do a show.
So the show have to go into somewhere then.
Then after the show you get new and then we added edit create opt out and delete or destroy.
So the issue has to come on than the the index.
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
I add any variables to this show I change soon.
I just want to quickly run the racz command so that I can just highlight something to look to been slashed
rails grout and those shows or the client raoult we have so we can see here from all the routes we have.
We can see the one for this show here so you can see where the post is the action if they get where
you run the post requires an eye here and you've got the format.
It also requires action cords show in the post controller so the syntax the actual hadeed it tells the
reals that this route expects an I.D. parameter.
Okay which is in our case will be the idea of the post.
So now that we've got that out of the way I just wanted to see that less.
Now add it in to this show action.
So the way we did it we had before had the variable pulse.
And when I said that to you of course to post model this is the model because you can see the upper
case P indicates that is a class.
You don't find and don't pass it.
The ramps
and inside the paradigms we pass him the idea.
So when the post is posted or when the funds are submitted it should have an A D to identify that post
will put the Aidy there.
So let me just explain this line here.
What I have done here.
So we amusingly post doc find to find the post that we will be interested in.
As any post that's been submitted we use in the post of find to find the post and were passing in the
programs I took So to get the idea parameter from the request.
So when the form finally of me to one I get the idea from that submission.
And pass it on to the value of the paramus saw and also have used an instance of the variable which
is prefixed with the at symbol.
This is an instance of the pulse variable saw using that to hold or store a reference to the article.
Sorry to the post object.
So my using that to store a reference to the post object.
The reason we have to do this is that rails will pass all instance variables to the view.
Okay so it's important that we are able to bring friends an instance or hold an instance of that post
object.
Okay so now that we've got the issue access or do we have to create a corresponding view so to do that
we go to the use.
So caught up fully views this is a views we go to post.
We've already got two views in there.
Right click on post and click new 0 2 file save us.
I am going to call this show
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
tags.
That's going to start with his team multipack some and I hate to tag here and our just inside them go
to embed Ruby So this is the embedded Ruby and you do that with a percent sign good set.
Give it the value equals two.
I'm going to sell it to the post under Title
K and then I'll close that close that tank and also close the Hakes to tack.
Mean create a paragraph to the p tag to create a paragraph again and when I'm in bed Ruby site is sent.
It was too big to send that to the post dog body.
Okay.
Close that and then close the tag.
The HTP tag then are saved that saw when the form is sound when you submit it is sure the title and
the body.
So now that we've got the action sorted now we've also got the show template sorted.
We should be able to post something and see what we've posted.
So let's let me refresh the form refresh this.
Okay this is a previous post you can see is now showing.
Not so if I want to.
You can see this is the idea I was talking about.
This is the idea of the post.
So let me just amend that and typing new knew that we can add another post just to see it working right
side.
Just say
hey.
Thanks for watching.
I said this it will pause and redirect to the show.
Okay.
Now you can see there this is the actual issue here.
So their vows sent.
I've just submitted it redirects to the view.
You can see this is the idea of the portrait.
This is post number three.
So at the moment there is no way of listing everything we've posted.
So in the next lecture we are going to sort that out so everything that gets posted can be listed on
the page.
Thanks for watching.