How do I undo Rails template generation in Haml?

笑着哭i 提交于 2019-12-11 02:32:34

问题


I installed a new gem to my Rails project - 'phrasing' - which has gem dependencies on multiple Haml gems. I need the gem (it is adding some phenomenal functionality to my project), and need the dependencies to be installed, but now when I run rails generate scaffold, all of the view templates are generated in Haml rather than ERB. I need views to continue to be generated in ERB.

I reviewed several previous StackOverflow articles, but most focus on converting TO Haml, and the answers around making sure that ERB is the default generator refer to removing lines from the config files, which are not there in my case (it appears that the gems are controlling the default layout format somehow).

(Note: While I appreciate that there may be several advantages to using Haml, and I might consider using it in a new project, I'd like to keep this one consistent, and it's already 80% finished in ERB.)


回答1:


Turns out this was as simple as adding the following into class Application in the config/application.rb file:

config.generators do |g|
   g.template_engine :erb
end

Still not sure why the manual override was necessary, but it is. This fixes it.



来源:https://stackoverflow.com/questions/27829085/how-do-i-undo-rails-template-generation-in-haml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!