> Is scaffolding continuing as normal?
> When I see posts about getting rid of dynamic scaffolding, does that
> refer to scaffolding .erb templates, or to the scaffold controller
The current plan (as far as I'm aware) is to keep generated
scaffolding, but replace the old-style scaffold templates with ones
meant for restful resources. Most or all of this work has already
been done in trunk. The new templates use the .erb extension.
OK, so the new .erb scaffolding templates are the ones to use. (Thank you.)
> The scaffolding templates all use
> <% for x in y %>
> instead of
> <% x.each do |y| %>
> Total subtle psychological difference, but with Rails having such
> incredible success, a little thing like that will encourage a lot of
> new Ruby programmers to use iterators instead of explicit iteration.
There is an assumption that web developers build the models and
controllers of a Rails app, but designers often build the view
templates. The assumption continues that designers are less likely
to know Ruby, so code in templates should be as accessible as
possible. To a designer familiar with PHP or Perl, the 'for user in
users' style of enumeration is probably more accessible than the
'users.each do |user|' style.
True; but encouraging programmers new to Ruby to write their code as
if it were PHP isn't going to result in beautiful code. The risk
you're taking there is of a glut, in a few years' time, of ugly Rails
code based on PHP programmers building by guesswork. There's already a
ton of it out there, and as the momentum keeps building, there will
only be more.
> Using iterators in the
> scaffolding is kind of like putting out a welcome mat, and encouraging
> people to leave their bad habits at the door.
Perhaps it's more like putting out a welcome mat written in a
language your friends understand but your guests don't.
I think you might be overestimating the difference between these two
lines of code. An each may look somewhat unfamiliar, but it probably
won't actually result in anyone's head exploding. I mean the word
"each" is a relatively intuitive word, and people who are
**completely** new to programming often find it **more** intuitive
than a for loop.
Seriously. I once taught some college girls Java. They couldn't wrap
their heads around it. The irony is that a year before they had done
Scheme and had no trouble with it at all. Recursion and lists are much
more intuitive to the complete novice, because the ideas are more
elegant. For loops are pretty weird to people who aren't used to them.
The only people who find for loops intuitive are people who are used
to them because they've been exposed to bad programming languages for
a significant amount of time.
Personally, I never use the for style enumerators, but I don't use
scaffolding for anything except throwaway code either. YMMV.
No, of course my mileage doesn't vary. What kind of moron would I have
to be for my mileage to vary from that? Thanks a lot. Jesus.
I'm right there with you, but that's the problem. I'm right there with
you because I know better. If all the experienced programmers avoid
for loops and scaffolding teaches for loops, that creates an
unnecessary rift between experienced programmers and newbie
programmers. You want that divide to be a gentle continuum. It's like
Kathy Sierra's graph, the curve from "I suck at this" to "I rock at
this." You want users to scale that curve as quickly as possible.
It's like the way acts_as_taggable is used in applications all over
the place. It was just designed as a demo for polymorphic
associations, but people saw it, copied it, and put it in production
code. If you give people an example of how to do things, that's how
they will do things. It's the power of monkey see, monkey do. Since
you know monkey see, monkey do is going to happen, you might as well
plan for it and do some good with it.