有没有一种方法可以配置Rails默认使用Haml,例如在生成scaffold时会相应地生成`scaffold_name/index.html.haml`而不是`scaffold_name/index.html.erb`?
类似于如何添加`config.sass.preferred_syntax = :sass`到`config/application.rb`中并默认生成`scaffold_name.sass`。
尝试将以下内容添加到`config/application.rb`中。
类似于如何添加`config.sass.preferred_syntax = :sass`到`config/application.rb`中并默认生成`scaffold_name.sass`。
尝试将以下内容添加到`config/application.rb`中。
config.generators do |g|
g.template_engine :haml
end
但最终得到了以下结果
$ rails generate scaffold foo name:string
invoke active_record
create db/migrate/20120208152550_create_foos.rb
create app/models/foo.rb
invoke test_unit
create test/unit/foo_test.rb
create test/fixtures/foos.yml
route resources :foos
invoke scaffold_controller
create app/controllers/foos_controller.rb
error haml [not found]
invoke test_unit
create test/functional/foos_controller_test.rb
invoke helper
create app/helpers/foos_helper.rb
invoke test_unit
create test/unit/helpers/foos_helper_test.rb
invoke assets
invoke coffee
create app/assets/javascripts/foos.js.coffee
invoke sass
create app/assets/stylesheets/foos.css.sass
invoke sass
identical app/assets/stylesheets/scaffolds.css.sass
$ rails destroy scaffold foo
invoke active_record
remove db/migrate/20120208152550_create_foos.rb
remove app/models/foo.rb
invoke test_unit
remove test/unit/foo_test.rb
remove test/fixtures/foos.yml
route resources :foos
invoke scaffold_controller
remove app/controllers/foos_controller.rb
error haml [not found]
invoke test_unit
remove test/functional/foos_controller_test.rb
invoke helper
remove app/helpers/foos_helper.rb
invoke test_unit
remove test/unit/helpers/foos_helper_test.rb
invoke assets
invoke coffee
remove app/assets/javascripts/foos.js.coffee
invoke sass
remove app/assets/stylesheets/foos.css.sass
invoke sass
我创建了一个很好的捆绑命令来替换所有erb文件为haml文件,遵循这个屏幕录像,但我仍然对如何在创建脚手架时将其设置为默认值感兴趣!我该如何做到让默认生成haml文件(而不是erb文件)?