I'm developing a Rails3 engine application, and I want to use Haml for the views.
First, what I have done was to add this to the engine Gemfile:
gem "haml"
While I was testing my engine, it was working OK (I have used https://github.com/josevalim/enginex to generate the gem and test it with the dummy application).
My problems started when I tried to use the engine on a real Rails application. The application does not have gem "haml" on it's own Gemfile, and so it was not initializing Haml, so I was receiving template not found errors as it was not looking for the .haml views. I was thinking that by requiring Haml on the Engine it would be enought for it to be also required by the Rails application.
What I have done for now was to add a config/initializers/haml.rb on the engine with this code:
require 'haml'
Haml.init_rails(binding)
It's working now, but I'm wondering if this is really a good way to do it.
Why Rails is not calling Haml "init.rb" file and so initializing Haml correctly by just adding gem "haml" to the engine Gemfile?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…