Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda