Ruby on rails 如何禁用Draper装饰生成器?
在我的Rails 3.2应用程序的Ruby on rails 如何禁用Draper装饰生成器?,ruby-on-rails,ruby-on-rails-3,draper,Ruby On Rails,Ruby On Rails 3,Draper,在我的Rails 3.2应用程序的application.rb中,我有以下几行代码来禁用我不想要的脚手架生成器: module MyApp class Application < Rails::Application # rest of the config... config.generators do |g| g.helper false g.stylesheets false g.javascripts false
application.rb
中,我有以下几行代码来禁用我不想要的脚手架生成器:
module MyApp
class Application < Rails::Application
# rest of the config...
config.generators do |g|
g.helper false
g.stylesheets false
g.javascripts false
end
end
end
模块MyApp
类应用程序
应用程序正在使用,如果我运行
rails generate
,则decorator
将被列为可用的生成器之一。我假设在上面的列表中添加g.decorator false
将阻止rails生成scaffold SomeModel
生成decorator文件,但它们仍然被创建。谁能告诉我我缺少什么吗?Draper配置为默认为每个控制器构建装饰器。您可以在application.rb文件中增加一行来更改默认配置
module MyApp
class Application < Rails::Application
# rest of the config...
config.generators do |g|
g.helper false
g.stylesheets false
g.javascripts false
g.decorator false
end
end
end
这真的是你的问题吗?自从我第一次开始学习Rails以来,我就没有使用过脚手架。如果要禁用这么多脚手架功能,为什么不使用控制器生成器呢?我正在构建一个包含很多模型的大型应用程序,其中已经有了所有的HTML模型,因此我定制了视图生成器(并添加了i18n支持)。键入
rails g scaffold Thing title body:text option:boolean amount:integer other\u Thing:references
保存我:)是值得的
$ rails generate decorator foo