我们目前正在努力将我们的网络应用搜索引擎从 Stimulus 更改为 Turbo。
然而,我们不断从我们的脚本中收到一个 HTML 请求而不是 Turbo 请求,并出现错误:“</p>
ActionController::UnknownFormat “.
Trying to force the request into the Turbo format give the following error :
“ ActionController::UnknownFormat - SearchController#search is missing a template for this request format and variant.
request.formats: ["text/html"]
request.variant: []: “
我们使用的是 7.0.0-beta.5 Turbo 版本。
看法
<h1>All Apps</h1>
<%= turbo_frame_tag "record" do %>
<%= form_with url: "/search", method: :get , data: { controller: "search" } do |form| %>
<%= form.text_field :search , data: { action: "input->search#findResults" } %>
<% end %>
<% end %>
<%= turbo_frame_tag "apps" do %>
<ul>
<% @apps.each do |app| %>
<%= content_tag :li, app.name %>
<% end %>
</ul>
<% end %>
<turbo-stream action="update" target="apps">
<template>
<ul>
<% @apps.each do |app| %>
<%= content_tag :li, app.name %>
<% end %>
</ul>
</template>
</turbo-stream>
class SearchController < ApplicationController
def search
@apps = ItunesConnect::App.where("name like ?", "#{params[:search]}%")
respond_to do |format|
format.turbo_stream
#format.html { redirect_to root_url(search: params[:search]) } #for testing
end
end
end
有什么建议吗?