Override default scaffold generator in rails 3

前端 未结 5 1316
一生所求
一生所求 2020-12-30 05:28

I\'ve created a generator for a controller in rails 3. Now I want to use this generator as the default generator when using the scaffolding generator.

Is that possib

5条回答
  •  误落风尘
    2020-12-30 06:04

    You can override the templates that Rails uses for its generators. In this instance, just place the file at lib/templates/scaffold_controller/controller.rb and modify it how you wish. The next time you run rails g scaffold [modelName] it will pick up this new controller template and use it.

    This is covered in Section 6 of the Creating and Customizing Rails Generators official guide.

提交回复
热议问题