Apologies for what is a very basic question, but hopefully someone can
help me understand why the following is done in the Rails scaffolding:
Scaffolding creates, amongst others, these two methods in a controller:
‘new’ renders the ‘make new x record’ page. And ‘create’ deals with the
data sent back from the form on that page.
My question is - why does ‘new’ bother to create a new model object at
all? It’s not used in the rhtml template, and a new model object is
created as another new instance in ‘create’ anyway.
I’m not sure about this (a really new RoR user), but I’d say RoR uses
the @paper instance on the View as a container of the inserted form
values, thus resending the new information back to the controller
(after a Submit action) encapsulated on the object (chech the params[]
hash to see how it travels).
But I could be wrong, since I’m recently learning this incredible and
interesting new framework
My question is - why does ‘new’ bother to create a new model object at
all? It’s not used in the rhtml template, and a new model object is
created as another new instance in ‘create’ anyway.
I dont think this is good advice. I definitely recommend that newbies
experiment with the built in scaffolding, to learn the rails
conventions and fundamentals. Then, move on, remembering Rails
scaffolding, you will probably write your own controllers. Or perhaps
pick up a plug in like Active Scaffold (which do I use and like alot,
btw) if you want ajaxy tables in your views.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.