Comments inserted below.

Did the generator add the validations for that attribute? 

>
> Did it add the code in the toy.rb that implements the business logic 
involving that attribute? 

Did it add the attribute to the views that do not just consist of the 
simplistic tables and so on generated by the controller? 

Did it add the required tests to make sure that all the uses of the 
attribute are correct? 

For the Rails generators and their options that I have discovered so far, 
the answer to all these questions is, obviously, No.

*Could* there be generators that do some of these things?  Yes.

*Are *there generators (or other tools) in the Rails World that do some of 
these things?  That's what I'm trying to find out in this thread.

So is it worth the hassle of messing about with the generator just for 
the few minor changes that it did make? 

As you develop an app starting with from a generated set of objects, the 
answer at first is clearly Yes.  As you manually modify the objects 
produced by prior runs of the generator, at some point the answer crosses 
over into No.  How soon you reach that point depends on the amount and kind 
of manual modifications you have made, vs the power of your generators to 
synthesize (or to help *you* synthesize) their new outputs with the manual 
refinements.

The synthetic abilities of the Rails generator that I've tried so far 
(basically *scaffold* and whatever it invokes) seem to be limited to: 

1. Detecting whether an object that it is about to generate already exists.
2. If so, detecting whether the existing and new versions of the object are 
identical.
3. If the versions are not identical, showing you a diff between them.
4. Giving you a choice between keeping the old version or replacing it 
*entirely 
*with the new version.

I haven't yet found any help from Rails tools with synthesizing the old 
(manually modified) and the new (generated) versions of a *particular* 
object.  I'll mention just two possibilities:

   1. Even a tool that compares two files textually and helps you merge 
   them by picking line-by-line between the two versions would be a 
   significant help.  
   2. Better yet would be a "smart generator" - perhaps better called a 
   *synthesizer* rather than a generator - that knows the structure of 
   Rails objects and uses that knowledge to make (or at least suggest) 
   syntheses of old and new object versions that preserve the functionality of 
   both.  For example, to address one of Colin's questions, suppose a 
"validates 
   :name, presence: true" validation had been added to the Toy model before 
   the new "size" column was added to the database.  A synthesizer would 
   recognize a validation declaration, and it would know that a validation 
   declaration on one attribute is independent of the existence of another 
   attribute, so it would leave the validation in place *and *add the new 
   attribute to all the Rails objects where it is relevant.  Or, more 
   cautiously, the synthesizer would *suggest *this synthesis to the 
   developer and let the developer decide.  A suite of synthesizers that 
   worked like this would extend the value of running generators/synthesizers 
   waaay deep into the Rails development process.  And such synthesizers are 
   especially doable in Rails because they can exploit the fact - which even 
   us newbies can see and appreciate - that Rails is a highly structured, and 
   *well*-structured, system.
   
Sorry to get into sermonizing.  All I really want from this thread is to 
learn if any tools or facilities that provide additional 
generating/synthesizing functionality currently exist in the Rails World.

~ Thanks yet again
~ Ken

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/abfb70b4-bd2c-4f80-896d-d9d04de1a69d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to