Ad

Rails 7 Missing Partial

- 1 answer

I am upgrading to Rails 7.1 and get a weird error in a view using a JS partial:

Missing partial account/_stripe.js.erb, application/_stripe.js.erb with {:locale=>[:fr], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}.

Here is my code to render the partial (it works well with Rails 6):

<%= render "stripe.js.erb" %>

The partial is located in the same folder as the view and is named "_stripe.js.erb".

I tried to replace the name of the partial, as suggested, by account/stripe, account/stripe.js, account/stripe.js.erb, stripe, stripe.js, none works.

Any idea how to solve this with Rails 7? Thanks.

Ad

Answer

Having an extension in the partial name was deprecated in Rails 6.1 and removed in Rails 7. You should use the following syntax:

<%= render partial: 'stripe', formats: :js %>
Ad
source: stackoverflow.com
Ad