I know the scaffold generator is really only useful for beginners and/or very the preliminary state of a project, but I find that I use it a lot (especially, since I am still a beginner). There are a couple of things I find myself tweaking (or wanting to tweak, but never getting around to tweaking) each time I generate a new scaffold: 1) Change the layout from blah.html.erb to application.html.erb, and delete blah.html.erb (errr, well, I copy the first one over, change the heading, and then delete it.) 2) Change the new and edit templates to render a common partial (a la Akita on Rails'' excellent article http://akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial) I suppose I could write my own scaffold generator (copying most of it from the existing scaffold generator). Or I could modify the existing scaffold generator to allow for user defined enhancements, and possibly even do so in such a manner as to be able to submit it upstream as a patch/enhancement. Or I could ask if such a feature already exists. I''m starting with the last option :-) --wpd -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 10, 2009, at 3:43 PM, Patrick Doyle wrote:> I know the scaffold generator is really only useful for beginners > and/or very the preliminary state of a project, but I find that I use > it a lot (especially, since I am still a beginner). There are a > couple of things I find myself tweaking (or wanting to tweak, but > never getting around to tweaking) each time I generate a new scaffold: > > 1) Change the layout from blah.html.erb to application.html.erb, and > delete blah.html.erb (errr, well, I copy the first one over, change > the heading, and then delete it.) > 2) Change the new and edit templates to render a common partial (a la > Akita on Rails'' excellent article > http://akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial) > > I suppose I could write my own scaffold generator (copying most of it > from the existing scaffold generator). > > Or I could modify the existing scaffold generator to allow for user > defined enhancements, and possibly even do so in such a manner as to > be able to submit it upstream as a patch/enhancement. > > Or I could ask if such a feature already exists. > > I''m starting with the last option :-) > > --wpd >You want to take a look at Ryan Bates''s Railscasts #058 "How to make a generator" I did exactly that back in June 2009 when I had a clean slate project that was going to have several vanilla models for an admin back-end. Scaffolding is great for that, but like you I always had a handful of tweaks. With my own "my_scaffold" generator, the layout has the changes I want, the controller actions do what I want (and redirect where I want), and I only had to make the changes once. (--to the generator templates of course) -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Patrick, I had the same idea a few months ago, and wrote a gem called “View Mapper” which does exactly this. See: http://patshaughnessy.net/view_mapper or: http://github.com/patshaughnessy/view_mapper The idea is that View Mapper will generate different variations of scaffolding code (called “views”) for different purposes: scaffolding + auto_complete, scaffolding + file attachments using Paperclip, scaffolding for two models in a has_many/belongs_to relationship, etc. Each of these variations is implemented by a “View Mapper Module” – the idea is that anyone could write such as module; I’m planning on writing a tutorial soon on how to do this. Anyway, to make all of this possible I found a simple way to extend the standard Rails scaffolding without just copy/pasting the entire thing over and over again. Check out the code on github to see what I mean… and/or drop me a line if you’re interesting in learning more about the details. - pat http://patshaughnessy.net On Dec 10, 4:33 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Dec 10, 2009, at 3:43 PM, Patrick Doyle wrote: > > > > > > > I know the scaffold generator is really only useful for beginners > > and/or very the preliminary state of a project, but I find that I use > > it a lot (especially, since I am still a beginner). There are a > > couple of things I find myself tweaking (or wanting to tweak, but > > never getting around to tweaking) each time I generate a new scaffold: > > > 1) Change the layout from blah.html.erb to application.html.erb, and > > delete blah.html.erb (errr, well, I copy the first one over, change > > the heading, and then delete it.) > > 2) Change the new and edit templates to render a common partial (a la > > Akita on Rails'' excellent article > >http://akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-f...) > > > I suppose I could write my own scaffold generator (copying most of it > > from the existing scaffold generator). > > > Or I could modify the existing scaffold generator to allow for user > > defined enhancements, and possibly even do so in such a manner as to > > be able to submit it upstream as a patch/enhancement. > > > Or I could ask if such a feature already exists. > > > I''m starting with the last option :-) > > > --wpd > > You want to take a look at Ryan Bates''s Railscasts #058 "How to make a > generator" > > I did exactly that back in June 2009 when I had a clean slate project > that was going to have several vanilla models for an admin back-end. > Scaffolding is great for that, but like you I always had a handful of > tweaks. With my own "my_scaffold" generator, the layout has the > changes I want, the controller actions do what I want (and redirect > where I want), and I only had to make the changes once. (--to the > generator templates of course) > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.