Hello and welcome.
In this picture we are going to add another action to our post control and the tone we're going to add
is a create action.
So we're going to enable us to create a new post in our previous like show we did here from use in the
form help.
So we're looking at the form here you can see we've got a helper here which is post on the path.
So what that does is it basically tells Real's to point the form.
Today you are right.
Patton associated with the post prefix.
So if we look at this script we used to create the form to create the resources.
When we did Real's routs and that showed us all the defined roles for our post results.
So looking at the defined roots here we can see that the path that pulls post on the score path our
tells Real's 2. the form to these you are a pattern associated with the post prefix and the form by
default will send it pulsed request to that room.
So these are the veres Type I request you to send a paused request.
For example if we wanted to create a new pause it was sent create post requests if we wanted to add
a new.
It does that you want or edit it does that if you want to show unsewn saw the polls underscore PAFF
helper is responsible for pointing the pointing rails to the relevant u r l which have been defined
here so points it to the rutz.
So if we try to say something now.
So if I say type 2 I just say test
body I say hello.
If I try to say this now I should get an error click say.
I'm expecting to get an error.
Okay so you can see here I've got an error here.
No my t's post slash new so you can see we got an error here.
So the server is not happy and he has complained and let his feelings know.
So basically what I've seen here the error messages sometimes are quite straightforward explanatory
saying that we have to perform an unknown action the action create could not be found for the post control
us so busy telling us that this is a post quantrell I hear we've got index methode index action new
action but we haven't got action to create.
So basically what we need to do is create one.
So come here and type in def create of course when you enter your post it creates it.
So you need a method or an action to take care of that.
So we've got that done now.
My indentation is not that brilliant but it doesn't really matter.
We just want to get the code working.
So now if I refresh all falling should should be okay now and give it a few minutes to refresh.
Okay so now if my post again I shouldn't get any errors because I've now created this action called
create cyclic currency.
Nothing will happen but I should not get an error or you can see it returns back to the same page.
The reason nothing happens when I resubmitted the page is because by default reals returns it to zero
for error.
What that means is that he's in no.
No content response for an action.
So if we don't specify what the response should be we just get he just returns to dippie to what we
need to do.
Now we need to we've just added to create action but we didn't specify anything about how the response
should be.
So what we need to do quote back into the controller and within the create action we should edit it
to specify what type of response we are expecting when we submit the form.
Ideally create action when you submitted should save the new post to the database.
So before I head it be quick action.
I just wanna explain something here.
So when a form is submitted for this form when it is sub me to the fields of the form.
So these are fields here and we've got title and we've got body the actual fields or the form are sent
to the rails application as para methods.
Okay so these parameters can then be referenced inside the controller actions.
So a typical is to perform a task.
You need to edit the create action here.
I just need to for us to see what was submitted.
I need to specify what should happen.
So in here I am just going to tab down and typing.
I want the form to render something so I'll see a render plain just going to end up playing along and
do parramore sounds for parameters render programs.
I'm going to put the symbol file Larry.
Inside there are past posts.
Okay and do a dot inspect.
To what should happen when I asked resubmit for a tool outpoured what I've submitted in car like an
object with to scour like a J sun object.
So let me say that.
Okay so let me submit the form again.
Ah click refresh that and then put the title in again to see test.
Just say hello and click save.
You can see now we've got the parameters displayed.
Come on like a sun object saw this clear was happening here.
The rynd Method.
This render method here is take in a hash with a key off plane.
OK.
So this is taking a hash.
The key is plain and the value of paramus which is a prime it.
Okay which is a post.
Inspect.
So we see whether value seen as prime is inspected less what is displayed here.
The paramus Method is the object which represents the parameters or the fields which any time the form.
Anything we intend the form is represented by the para rahm's object.
So all the paramus metod returns an action controller which is a Param in those object which allows
you to access the keys of the hash is in either strings or symbols in this equation.
The only parameters that actually matters are the ones that we have submitted on the form which is the
title and the body.
So as you can see we got the but we suddenly turn the lafont been displayed here.
This is not how we wanted to display later.
Later we're going to be.
The data is going to be saved in the database and retrieve from the database.
We just want to at this stage to prove that we do what ever we submitted to the form.
We can see it one way or the other.
So that's it for this liqueur.
This nature has taken a bit longer than expected so I do apologize.
Thanks for watching.
Bye for now.