如何让我的虚拟应用程序使用引擎的模板引擎?
我正在开发一个 Rails 引擎,并且 gemspec 具有以下内容:
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"
但是,在转到正确的控制器/操作时,我收到此错误:
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"
注意到处理程序部分吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在
lib/your_engine.rb
中需要 gem。如果您只在虚拟应用程序的 config/application.rb 中需要它,那么其他人在将您的引擎包含在他们的应用程序中时也会遇到同样的问题。这可能会特别令人困惑,因为在常规 Rails 应用程序开发中。依靠
Bundler.require
为您加载所有 gem 是很容易的。参考:避免使用
Bundler.require
的 5 个理由You should require the gem in
lib/your_engine.rb
. If you only require it in your dummy app'sconfig/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.Reference: 5 Reasons to Avoid
Bundler.require
我也遇到了类似的问题,虚拟应用程序未加载 Devise。我所要做的就是在 config/application.rb 中需要它,然后它就起作用了。也许您只需要在那里
require 'slim'
就可以了?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 torequire 'slim'
there and it will work too?