覆盖缺省Rails的模型模板 [英] Override the default Rails model template

查看:118
本文介绍了覆盖缺省Rails的模型模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要重写,它将与默认生成的模型文件轨生成模型。我创建了一个基于<一个模板href="https://github.com/rails/rails/blob/master/activerecord/lib/rails/generators/active_record/model/templates/model.rb"相对=nofollow>这个文件,但我想不出哪里把它。其他的答案似乎说明 /lib/templates/rails/model/model.rb /lib/templates/rails/model/model_generator.rb ,但那些都做任何事情 - 我把模板中的位置,但是当我运行轨生成模式MODELNAME 它被忽略

I want to override the default model file that's generated with rails generate model. I've created a template based on this file, but I can't figure out where to put it. Other answers seem to suggest /lib/templates/rails/model/model.rb or /lib/templates/rails/model/model_generator.rb, but neither of those do anything - I put the template in that location but when I run rails generate model ModelName it gets ignored.

我要对这个正确的方式?我应该在哪里把模板?

Am I going about this the right way? Where should I put the template?

推荐答案

解决:我想的lib /模板/ active_record /模型/ model.rb

这篇关于覆盖缺省Rails的模型模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆