Hey I'm new to turbo_streams and am stuck on why I'm getting this error.
Properties partial:
<div id="properties"
data-action="map-marker-clicked@window->@mapmarker#mapMarkerClicked"
data-controller="mapmarker"
data-mapmarker-target="properties_list">
<%= "#{@properties.length} properties" %>
<%= turbo_stream_from "properties" %>
<%= turbo_frame_tag "properties" do %>
<% @properties.each do |property| %>
<%= render property %>
<p>
<%= link_to "View this property", property %>
</p>
<% end %>
<% end %>
</div>
And my controller:
def index
@properties = location_search? ? Property::SearchByLocation.call(search_params[:value]) : Property.all
@markers = Property::GenerateGoogleApiMapMarkers.call(property_or_properties: @properties)
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.replace(@properties, partial: 'properties/properties')
end
end
end
Bit more context: I plan to trigger this reload from a stimulus controller (when the user clicks a marker on the google maps I want to refresh the properties section with the coordinates of the marker as the way to organise the properties (the closest to the marker would show at the top).
I get the ActionController::UnknownFormat error when I go to http://localhost:3000/properties

I suppose the request that triggered the error was an HTML request (without the Accept: text/vnd.turbo-stream.html HTTP header).
You can verify this by checking your application logs. For each request, you'll find a line indicating which format is use to process it. In your case it should be something like:
Processing by PropertiesController#index as HTML
In your controller, the respond_to block only contains format.turbo_stream as accepted MIME type :
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.replace(@properties, partial: 'properties/properties')
end
end
As a result, your action is unable to render HTML, resulting in an ActionController::UnknownFormat error.
In order to fix this issue you should enable HTML responses as so:
respond_to do |format|
format.html { ... }
format.turbo_stream do
render turbo_stream: turbo_stream.replace(@properties, partial: 'properties/properties')
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With