How to render partial a js.erb file in Rails 7

This works in Rails 6.1 but not in 7.0: Error message:

Missing partial reports/_ingest_chart.js, application/_ingest_chart.js with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}.

code: …script type=“text/javascript”> <%= render partial: ‘ingest_chart.js’ %>

File is reports/_ingest_chart.js.erb

Note :formats=>[:html] in the error message. Since you’re responding to an HTML request, it’s looking for HTML templates. To override this default, your render call can do this:

<%= render partial: ‘ingest_chart’, formats: [:js] %>
1 Like

Thanks a lot, that works.