On Jun 6, 2015, at 4:31 PM, kenatsun <[email protected]> wrote:

> 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:
>       • 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.  
>       • 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.
> 

I don't know of any within the true meaning of "generator" that do all that you 
have outlined here. But there are systems that ape the Django admin view 
(RailsAdmin etc) that introspect your database and build an interface to modify 
it on the fly. This is similar to how the Scaffold system in Rails worked in 
versions less than 1 (and maybe a few minors after 1). The problem with these 
systems that I have encountered is that they have a well-formed opinion of how 
any type of field should be represented, and in what order, and they build you 
an 80% solution in no time at all. If you're happy with what they give you, 
then you're completely set. But if you want something even a little bit off the 
tracks they've laid, then you have a whole world of work to fake them into 
giving it to you. 

Rails took a different path after that first foray into 
scaffolding-by-introspection, and decided that they would make it really cheap 
and easy to get a static file, and then let you modify it later as you go. I 
believe the thinking was that there was no way a professional would not exert 
themselves to make a truly custom application if that was what they were being 
paid to do.

One thing you might try is after you've made significant changes, try making a 
new stunt-double app with the generator, with the new version of your schema. 
Then copy the relevant files over to your actual working app. You'll be able to 
cherry-pick which parts of the new code make sense, so you don't have the 
generator overwrite something you spent time customizing.

Walter

> 
> ~ 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 [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/abfb70b4-bd2c-4f80-896d-d9d04de1a69d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/F05553DD-F0B0-442B-B69B-4CC4E6DEF0FE%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to