All threads / Hotwire missing template on form submission
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Hotwire missing template on form submission

Thomas McDonnell asked in Gems / Libraries

Hi Chris/extended go-rails community :)

I have been playing around with the new turbo rails and trying to implement a turbo stream for my login form submission errors. I am wondering if anyone else has come across this issue, my form submission takes place as it should and on turbo format response it looks as though it is working correctly and rendering the form template with errors, however, I am getting a 500 missing template error ActionView::MissingTemplate (Missing template <turbo-stream action="replace" target="new_user_session"><template><form id="new_user_session" class="grid grid-cols-6 gap-2" data-controller="accounts--form" action="/accounts/sessions" accept-charset="UTF-8" data-remote="true" method="post"><input type="hidden" name="authenticity_token" value="fJcDVQYgDyfW53OdG5D7wptzyLMu6qS/CGgBhoTunJKNb8Ri9QBAHxY3eCuYhi6f29wYaqwzP/j1A6W8FtzLMw==" />
<div class="col-span-6 field">
<div class="field_with_errors"><label class="block text-md font-medium text-gray-700" for="user_session_email">Email</label></div>
<div class="field_with_errors"><input class="mt-1 bg-gray-100 focus:outline-none focus:ring focus:border-purple-300 focus:bg-white border border-gray-200 block w-full sm:text-sm rounded-lg py-3 px-4 mb-3" required="required" type="email" value="test@t.com" name="user_session[email]" id="user_session_email" /></div>
</div> .....
which is confusing me as I can't think of what template it is looking for as the error correctly renders the form with errors so it's not the form partial.

Running Rails 6.0.3.4 and Ruby 2.7.0

Three days on this, digging into source code of turbo-rails and seeing how it works only to find it was a simple syntax error LOL The error messages could be better I think, but then again I could have just put my glasses on earlier to :)

Hi Thomas!
Can you share what you found? (Regarding the syntax error)
I am a bit stuck myself too.

Hey Francisco. Just ran into this myself, not sure if you are still looking into this, but my problem was with a render call I was making in the controller

Bad syntax:

render turbo_stream.replace(
dom_id_for_records(@commentable, @comment),
partial: 'comments/form',
locals: { comment: @comment, commentable: @commentable }
)

Good syntax:

render turbo_stream: turbo_stream.replace(
dom_id_for_records(@commentable, @comment),
partial: 'comments/form',
locals: { comment: @comment, commentable: @commentable }
)

...difference being the turbo_stream: after render

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 62,791+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.