2

I am looking to not only customise my erb scaffold templates but also to add new templates.

In ScaffoldGenerator < Erb::Generators::Base I can see there there is a way to provide additional templates in %w(index edit show new _form).

So I have created a custom erb generator and templates directory in my application in lib/generators/erb/scaffold/.

However when I run rails g scaffold Something, my custom generator is not picked up by via scaffold_controller. Does this mean I need to provide a custom scaffold generator to use a custom scaffold_controller generator just so it can then use my erb generator?

I can also see the scaffold argument:

ScaffoldController options:
  -e, [--template-engine=NAME]  # Template engine to be invoked
                                # Default: erb

Am I able to provide my erb generator as the template engine to be used?

(Using Rails 4)

Sash
  • 4,448
  • 1
  • 17
  • 31
  • Pretty much answers my question here http://stackoverflow.com/questions/4696954/how-to-have-the-scaffold-to-generate-another-partial-view-template-file?rq=1 – Sash Jan 03 '15 at 11:13

1 Answers1

3

lib/templates/erb/scaffold is the correct path for rails scaffold.

Just in case...

model goes in /lib/templates/active_record/model/model.rb

controller goes in /lib/templates/rails/scaffold_controller/controller.rb

lulalala
  • 17,572
  • 15
  • 110
  • 169
Fazel
  • 33
  • 4