如何让我的虚拟应用程序使用引擎的模板引擎?

发布于 2025-01-01 05:52:15 字数 901 浏览 1 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小嗷兮 2025-01-08 05:52:15

您应该在 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'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.

Reference: 5 Reasons to Avoid Bundler.require

红玫瑰 2025-01-08 05:52:15

我也遇到了类似的问题,虚拟应用程序未加载 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 to require 'slim' there and it will work too?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文