Scott & Colin ~
Perhaps this conversation has reached the end of its useful life. But in
case there still is anything left to be learned, let me respond to a couple
of your comments.
"Why on earth would you keep re-generating scaffolds over and over???"
[Scott]
Because generators, when they work, are easier and more reliable than
manually updating code. Rails obviously has a powerful set of generators
for jump-starting development. That's one big reason why I'm spending all
this time evaluating it (vs other platforms like Django). This whole thread
is trying to understand the powers and limits of the Rails generators,
specifically in the somewhat-Rails-nonstandard scenario where the DB schema
exists independently of the Rails app, so the requirement is to tailor (and
re-tailor) the Rails objects to fit the DB schema, with as much automagic
support as possible. Of course, the job of generators rapidly becomes
harder when you ask them to update objects that have been modified manually
since they were originally generated. But some generators can go farther
into update-land than others, and I'm trying to understand where Rails is
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 field
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 actually *knew
*which files had to be updated so that my app could handle the new database
column - another huge advantage for a newbie like me, who would otherwise
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 manually
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 (especially
in update-land) that I haven't discovered yet.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/548cae49-4a99-4634-aa51-1d01773544b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.