Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5.0.1 Missing template when adding haml-rails to a rails engine #124

Open
AndyCapiau opened this issue Mar 2, 2017 · 5 comments
Open

Comments

@AndyCapiau
Copy link

AndyCapiau commented Mar 2, 2017

In engine_name/engine_name.gemspec, I added:
s.add_dependency "haml-rails"

In engine_name/lib/engine_name.rb, I added:
require "haml-rails"

In engine_name/lib/engine_name/engine.rb, I added:

config.generators do |g| 
  g.template_engine :haml
end

I ran the 'bundle' command both in:

  • the engine directory
  • the test/dummy directory

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

@jakeonrails
Copy link

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).

@krisleech
Copy link
Contributor

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.

  • rails 5.0.6
  • haml-rails 1.0.0
  • haml 5.0.4

@krisleech
Copy link
Contributor

My solution, as per this comment, was to add require "haml" to lib/<PROJECT>/engine.rb.

@topherfangio
Copy link

Just ran into this with 5.2.3 and can confirm that adding require "haml" to my engine file fixed the issue. Thanks!

@nickpearson
Copy link

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])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants