7

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

enter image description here

Robert Faldo
  • 401
  • 7
  • 15

2 Answers2

2

You should add a default format.html action

Sumak
  • 927
  • 7
  • 21
0

Ran into the same issue and solved it by manually registering the mime type by adding the below line to config/initializers/mime_type.rb.

Mime::Type.register "text/vnd.turbo-stream.html", :turbo_sream

See https://github.com/hotwired/turbo/pull/93 for some background.