I have a folder structure like
project/app/views/api/users/_user.json.jbuilder
The error is
Searched in:
* "/Users/name/Desktop/etc/etc/project/app/views"
ActionView::MissingTemplate - Missing partial api/users/_user.json.jbuilder with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}.
I'm trying to render
<script type="text/javascript">
window.currentUser = <%= render("api/users/user.json.jbuilder",
user: current_user).html_safe %>
</script>
The exact same code worked in Rails 5.xx, but I'm on Rails 7.xx now and I'm stuck on this error.
In Rails 7, including the extension on the file results in an error.
Works and Rails is able to find the partial. The error message is pretty useless in this case because it just seems like you're doing it right. Also, I can't find any documentation at all on the options hash you're supposed to pass to render partial. My Github Copilot just auto-completed it for me, then I scoured the internet trying to find information pertaining to it but couldn't.
I'm assuming you just look at the error message
Then realize the options are locale, formats, variants, handlers?
Answer found here Rails 7 missing partial