Michael Schuerig
2005-Aug-19 18:10 UTC
Generators: understanding complex_template in scaffold_generator
I''m trying to understand why things are done the way they are in the scaffold generator. Right now, what I don''t get is why the _form.rhtml partial is generated from two parts. I see that the inner part is processed in a context where the tag helper methods are exchanged with implementations that write Rails-ERb code instead of HTML. But to me it is not obvious why it needs to be done this way, i.e., why isn''t this done with just a single part evaluated with the appropriate binding? Michael -- Michael Schuerig They tell you that the darkness mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org Is a blessing in disguise http://www.schuerig.de/michael/ --Janis Ian, From Me To You
Jeremy Kemper
2005-Aug-19 20:55 UTC
Re: Generators: understanding complex_template in scaffold_generator
On Aug 19, 2005, at 11:10 AM, Michael Schuerig wrote:> I''m trying to understand why things are done the way they are in the > scaffold generator. Right now, what I don''t get is why the _form.rhtml > partial is generated from two parts. I see that the inner part is > processed in a context where the tag helper methods are exchanged with > implementations that write Rails-ERb code instead of HTML. But to > me it > is not obvious why it needs to be done this way, i.e., why isn''t this > done with just a single part evaluated with the appropriate binding?Hi Michael, It''s done in this way so you can regenerate the form after you''ve created the database table: see the little-known script/update. This allows you to generate scaffolding, create the table, then update the scaffolded views with the forms appropriate for the new table. Perhaps this extra complexity isn''t worth it considering so few use it, much less are aware of it. Best, jeremy
Michael Schuerig
2005-Aug-19 22:17 UTC
Re: Generators: understanding complex_template in scaffold_generator
On Friday 19 August 2005 22:55, Jeremy Kemper wrote:> On Aug 19, 2005, at 11:10 AM, Michael Schuerig wrote: > > I''m trying to understand why things are done the way they are in > > the scaffold generator. Right now, what I don''t get is why the > > _form.rhtml partial is generated from two parts. I see that the > > inner part is processed in a context where the tag helper methods > > are exchanged with implementations that write Rails-ERb code > > instead of HTML. But to me it > > is not obvious why it needs to be done this way, i.e., why isn''t > > this done with just a single part evaluated with the appropriate > > binding? > > Hi Michael, > > It''s done in this way so you can regenerate the form after you''ve > created > the database table: see the little-known script/update. This allows > you to generate scaffolding, create the table, then update the > scaffolded views > with the forms appropriate for the new table. Perhaps this extra > complexity > isn''t worth it considering so few use it, much less are aware of it.Hi Jeremy, thanks for pointing this out, now I see it in the Update command. Neat! Michael -- Michael Schuerig Life is just as deadly mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org As it looks http://www.schuerig.de/michael/ --Richard Thompson, Sibella
Rick Olson
2005-Aug-19 22:43 UTC
Re: Re: Generators: understanding complex_template in scaffold_generator
> > It''s done in this way so you can regenerate the form after you''ve > > created > > the database table: see the little-known script/update. This allows > > you to generate scaffolding, create the table, then update the > > scaffolded views > > with the forms appropriate for the new table. Perhaps this extra > > complexity > > isn''t worth it considering so few use it, much less are aware of it.I saw that script today and had no clue what it was for. I think that is a very good use of it, in fact. Of course, this should just be easier for people to find. I should really look into doing my own scaffolding, since my form fields take a slightly different form (I use divs and label tags). Hmm, someday.... -- rick http://techno-weenie.net
> Perhaps this extra complexity > isn''t worth it considering so few use it, much less are aware of it. >There seem to be many things (some very cool) in Rails that aren''t documented anywhere or not in a place a mortal could find. How about a "Documentation Needed" section on the Wiki where an un- (or poorly) documented feature could be written up by someone in the know.
As far as I''m concerned, an "undocumented feature" is a documentation bug and should be treated as such. That said, a rapidly evolving environment such as RoR is going to have lots of them. The Ruby and Rails communities seem to be doing a great job of balancing programming, documentation and testing. I just hope the environment doesn''t change so fast that it gets created faster than I can learn it. :) Steve Downey wrote:> There seem to be many things (some very cool) in Rails that aren''t > documented anywhere or not in a place a mortal could find. > > How about a "Documentation Needed" section on the Wiki where an un- > (or poorly) documented feature could be written up by someone in the > know. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >