Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

A simple way to copy the default generator templates is needed

#4574

A great feature was added in Rails 3, the hability to easily personalize the output of the generators for each application, this can improve the productivity in many cases.
I missed this functionality for a long time, since I worked with Grails for some time, and now I think only a small piece of the grails functionality is still missing.
in Grails there is a task called "install-templates" that copies the default templates to the personalization folder.
I created a rake task and published it in gist to do this http://gist.github.com/396453
Im attaching a patch with this template too.<br/> The rake task name I created is templates:copy

Reported by Rodrigo Urubatan · May 11th, 2010 @ 02:04 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Rodrigo Urubatan
  2. Rodrigo Urubatan
    Rodrigo Urubatan
    • Tag changed from generator, personalization, templates to generator, patch, personalization, templates

    May 11th, 2010 @ 02:13 AM

  3. José Valim
    José Valim
    • Milestone cleared.
    • Tag changed from generator, patch, personalization, templates to bugmash, generator, patch, personalization, templates
    • State changed from new to open
    • Assigned user set to José Valim

    The idea seems good, but the patch needs to be improved. No need to load rubygems since you are already inside the railties gem (just use FILE). You should also use FileUtils.cp_r to simplify the code!

    May 11th, 2010 @ 02:33 AM

  4. Rodrigo Urubatan
    Rodrigo Urubatan

    DRYied up the code a little, removed the rubygems reference, now using FILE to lookup the directory, and using cp_r to simplify file copy.
    Any other suggestions are welcome.

    May 11th, 2010 @ 04:36 PM

  5. Jeroen van Dijk
    Jeroen van Dijk

    I like this idea.

    When I apply this patch it gives me errors for the mailer and I think the code can be cleaned up a bit. I also think this Rake task should be under the rails namespace.

    So I refactored the patch and I have tested it manually on a new application.

    It seems that the erb templates are not used by the "rails g" command, is that correct? Maybe we can remove those from the code? and make it more simple?

    May 14th, 2010 @ 11:00 PM

  6. José Valim
    José Valim

    erb templates are used by rails g command.

    I would like to credit Urubatan in this patch as well.
    Jeroen, is it ok if I change the author to "Jeroen van Dijk + Rodrigo Urubatan" so you both get the credit?

    May 15th, 2010 @ 08:33 AM

  7. Jeroen van Dijk
    Jeroen van Dijk

    For the record, as said on IRC, thats ok Jose! Thanks

    May 15th, 2010 @ 10:00 AM

  8. Repository
    Repository
    • State changed from open to resolved

    May 15th, 2010 @ 02:02 PM

  9. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM