Open AndyCapiau opened 7 years ago
I came here to report this same issue.
Adding haml-rails to the project that includes your Rails engine/plugin makes the problem go away, but I thought that adding haml-rails as a dependency would Just Work™.
Btw, I'm on Rails 5.1.x (and same version for the engine).
I get an error such as:
Missing partial screening/studies/_show with {:locale=>[:en], :formats=>[:js, :html, <snip>], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}.
Notice not haml
in the handlers. Is this the same error you get?
I have haml-rails
in Gemfile and require it in the engines ApplicationController
.
My solution, as per this comment, was to add require "haml"
to lib/<PROJECT>/engine.rb
.
Just ran into this with 5.2.3 and can confirm that adding require "haml"
to my engine file fixed the issue. Thanks!
Adding require 'haml'
to my engine file fixed the ActionView::MissingTemplate: Missing partial
issue for me as well in Rails 5.2 three years ago, but the problem resurfaced when upgrading to Rails 7 (not sure about 6 and 6.1) when using render_to_string
to render a partial inside an engine controller.
I found a commit in the kaminari gem that fixes seemingly the same issue by specifying the rendering format:
# this fails when called from an engine controller in Rails 7:
render_to_string(partial: 'table')
# specifying :html as a format makes it work:
render_to_string(partial: 'table', formats: [:html])
In _engine_name/enginename.gemspec, I added:
s.add_dependency "haml-rails"
In _engine_name/lib/enginename.rb, I added:
require "haml-rails"
In _engine_name/lib/enginename/engine.rb, I added:
I ran the 'bundle' command both in:
When going to the test/dummy directory and (re)start the rails server, when I then go to "localhost/engine_name/resource" I get a template missing.
The very same way of working, works fine in rails 4.2.8