Scott & Colin ~
Perhaps this conversation has reached the end of its useful life. But
case there still is anything left to be learned, let me respond to a
of your comments.
“Why on earth would you keep re-generating scaffolds over and over???”
Because generators, when they work, are easier and more reliable than
manually updating code. Rails obviously has a powerful set of
for jump-starting development. That’s one big reason why I’m spending
this time evaluating it (vs other platforms like Django). This whole
is trying to understand the powers and limits of the Rails generators,
specifically in the somewhat-Rails-nonstandard scenario where the DB
exists independently of the Rails app, so the requirement is to tailor
re-tailor) the Rails objects to fit the DB schema, with as much
support as possible. Of course, the job of generators rapidly becomes
harder when you ask them to update objects that have been modified
since they were originally generated. But some generators can go
into update-land than others, and I’m trying to understand where Rails
on this dimension.
“The only thing you have to do now is to add the new field to the
view. Everything else is handled automatically. All you are
achieving by running the generator is adding that field to the view.”
Not so, from my experiments. Running “rake db:schema:dump” added the
to schema.rb, and the output from *scaffold *indicates that it edited a
total of 8 different files for me, namely:
conflict test/fixtures/toys.yml force test/fixtures/toys.yml conflict app/controllers/toys_controller.rb force app/controllers/toys_controller.rb conflict app/views/toys/index.html.erb force app/views/toys/index.html.erb conflict app/views/toys/show.html.erb force app/views/toys/show.html.erb conflict app/views/toys/_form.html.erb force app/views/toys/_form.html.erb conflict test/controllers/toys_controller_test.rb force test/controllers/toys_controller_test.rb conflict app/views/toys/index.json.jbuilder force app/views/toys/index.json.jbuilder conflict app/views/toys/show.json.jbuilder force app/views/toys/show.json.jbuilder
Not only did the generator update all these files for me, but it
*which files had to be updated so that my app could handle the new
column - another huge advantage for a newbie like me, who would
have to spend hours figuring that out.
Were not all of these 9 edits necessary to weave the new database column
into my app?
So, what’s the best approach: Run 3 simple console commands, or
locate and edit 9 files (and debug the edits)?
I guess I see a lot more value in the Rails generators than you guys do.
And I’m still looking to see if they have still further powers
in update-land) that I haven’t discovered yet.