Hi you all, after creating an app I used the script scaffold to generate
the whole thing. After this, I have several doubts about the code
generated:
-
â??def indexâ?: This method calls the method â??listâ?. However, to display
the template â??list.rhtmlâ?, it also calls the â??render :action=>â??listâ?? â?.
Why? I mean, if we have previously called the method â??listâ?, this method
would also render the template, there will be no need to explicitly say
so. If not, we could have also used â??render :templateâ?, not render the
action. -
â??postâ?? is indicated in the destroy action, but not in others like
â??editâ? or â??showâ?â?¦ why? How can I know when I have to use the â??postâ? or
not? -
When we create a new element we call the â??newâ? action and then the
â??createâ? action. In both of them we are using the â??Thing.newâ? soâ?¦ are we
instantiating the thing twice?. I donâ??t understand this piece of code. -
For â??listâ? we use the pagination helper. The line of code is something
like:
â??@thing_pages, @things = paginate :things, :per_page => 10, :order_by =>
'demo_name’â? I donâ??t understand the line. I can understand the code
after the â??@things =â?, but not the â??@thing_pages,â? code. -
Iâ??ve also seen in tutorials with older versions that variables such as
â??flashâ? or â??paramsâ? are not passed with the at symbol. Do you know the
why of these change?
If anyone could answer any of these questionsâ?¦. Thanks!