Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Rails not able to find partial

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.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In Rails 7, including the extension on the file results in an error.

<%= render partial: "api/users/user", 
    formats: [:json], 
    handlers: [:jbuilder],
    locals: { user: current_user } %>

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

{:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}

Then realize the options are locale, formats, variants, handlers?

Answer found here Rails 7 missing partial

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!