Hey folks, I have a template which has two turbo frames:
## index.html.erb
<%= turbo_frame_tag(:content, data: { turbo_action: :advance }) do %>
<%# more html %>
<%= link_to(options_path, data: { turbo_action: :load, turbo_frame: :menu }, no_active_class: true, class: 'text-decoration-none') do %>
<%# more html %>
<% end %>
<%= turbo_frame_tag(:menu, data: { turbo_action: :load }, class: 'product-menu-popup') %>
<% end %>
Clicking the link loads the content of the following template in the turbo frame with id: menu
.
## menu.html.erb
<%= turbo_frame_tag(:menu, data: { turbo_action: :load }) do %>
<%# more html %>
<% end %>
However, there is a before_action
hook on the options_path
controller action that the link is requesting which sometimes (depending on user state) redirects to another page:
def web_authenticate_pin
if !verify_pin(user, pin) #validates whether the user pin is still valid or not
redirect_to web_enter_pin_path and return
end
end
The above is creating a problem: when the user clicks the link and the pin is invalid I can see that the redirect happens but the page is not being updated, instead I get Content Missing
for the menu id turbo frame and this error in the console:
Error: The response (200) did not contain the expected <turbo-frame id="menu"> and will be ignored.
Would appreciate thoughts on how I can handle this scenario, since I do want to render the content in menu and only if the before_action
commit redirects do I want to update the full page.