How do I get my dummy app to use the Engine's template engine?

爱⌒轻易说出口 提交于 2019-12-23 12:57:50

问题


I have a Rails Engine I'm working on and the gemspec has this:

s.add_development_dependency "rspec-rails"
s.add_development_dependency "combustion"
s.add_development_dependency "capybara"
s.add_development_dependency "factory_girl_rails"
s.add_development_dependency "ffaker"
s.add_development_dependency "draper"
s.add_runtime_dependency "sqlite3"
s.add_runtime_dependency "slim-rails"
s.add_runtime_dependency "sass-rails"
s.add_runtime_dependency "jquery-rails"
s.add_runtime_dependency "rails", "~> 3.2"

However upon going to the correct controller/action I get this error:

Missing template countdown/subscriptions/index, countdown/application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in: * "/Users/krainboltgreene/Repository/ruby/countdown/spec/dummy/app/views" * "/Users/krainboltgreene/Repository/ruby/countdown/app/views"

Notice the handlers part?


回答1:


I had a similar problem with the dummy application not loading Devise. What I had to do was require it inside config/application.rb and then it worked. Perhaps you just need to require 'slim' there and it will work too?




回答2:


You should require the gem in lib/your_engine.rb. If you only require it in your dummy app's config/application.rb, then others are going to have this same problem when include your engine in their apps.

This can be especially confusing because in regular Rails app development. It's easy to rely on Bundler.require to load all of your gems for you.

http://myronmars.to/n/dev-blog/2012/12/5-reasons-to-avoid-bundler-require



来源:https://stackoverflow.com/questions/9073272/how-do-i-get-my-dummy-app-to-use-the-engines-template-engine

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