Questions tagged [turbo]

201 questions
3
votes
2 answers

How do I correctly render images via Hotwire Turbo streams?

My problem: When rendering images using Hotwire/Turbo, all URLs render with host example.org instead of my actual hostname. Regular views are fine, but rendering partials through a Turbo stream leads to ActiveStorage URLs like…
aidan
  • 1,627
  • 17
  • 27
3
votes
1 answer

In a Hotwire/Rails app, when to use target: '_top' for a turbo_frame?

The turbo handbook explains target: '_top' here and here. But I still don't understand what's the difference between these two forms: #1 <%= turbo_frame_tag 'new_search', target: '_top' do %> <%= search_form_for :q do |f| %> ... <% end…
hungmi
  • 335
  • 7
  • 11
3
votes
1 answer

Hotwire turbo streams returning head :no_content

I have a system with posts and comments, each Post has_many Comments. I am trying to setup a turbostream so that when you post a comment it displays immediately. Everything works in that data is persisted to the database but it seems like the turbo…
tfantina
  • 788
  • 11
  • 37
2
votes
2 answers

Turbo-Rails: How can I add add a Turbo Frame to `application.html.erb`?

I ran the following in the command line: > rails new test-turbo > rails g controller Home index Added the following route to config/routes.rb: resources :home, only: [:index] Wrapped the <%= yield %> in app/views/layouts/application.html.erb in a…
a-lavis
  • 33
  • 4
2
votes
0 answers

Environmental variables in Turbo

I am trying to use an environmental variable defined in my local .env file in one of my turbo packages, but it always comes up as undefined. I am using Turbo to manage my monorepo. The app is build in Next.js/React/Typescript. My folder structure…
2
votes
1 answer

Rails 7 stimulus controller not registering

After pinning the library ./bin/importmap pin stimulus-library, the config/importmap.rb reads as pin "application", preload: true pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true pin "@hotwired/stimulus", to:…
Jerome
  • 5,583
  • 3
  • 33
  • 76
2
votes
1 answer

rails turbo frame apparently updating but browser window remains unaltered

The following _receipt_number partial (HTML formatting tags removed for brevity's sake) <%= turbo_frame_tag :receipt_number do %> <%= t('scan') %> <%= t('cart.receipt_number') %>

<%= @cart.receipt_number %>

<% if…
Jerome
  • 5,583
  • 3
  • 33
  • 76
2
votes
1 answer

Failed to execute turbo code: 2, kind: NotFound, message: "No such file or directory"

I have had an issue the last few days, I hope I gonna resolve it with your help. I created a project with a turbo package When I want to build a docker file with the docker-compose file I got that error. Thank you Error thread 'main' panicked at…
2
votes
0 answers

Using turbostreams in Rails to re-render a partial using a collection that depends on a date range set within the controller

I'm trying to add live update functionality to a statistics page using Turbo. The page has a user-set date range with a simple filter using url params. The value of each stat is determined by summing values of a collection of objects (matched by the…
daveanderson88
  • 327
  • 1
  • 4
  • 12
2
votes
2 answers

Infinite scroll pagination and filter with hotwire

I have a table with infinite scroll working perfectly without reloading entire page. I'm now having issues with adding filter. Thanks to Phil Reynolds' article https://purpleriver.dev/posts/2022/hotwire-handbook-part-2 I was able to implement…
2
votes
1 answer

data-autoscroll-block "start" position of turbo_frame option is misaligned

I would like to use the data-autoscroll-block attribute described in Turbo Reference to set the scroll position to TOP when screen transitions by turbo_frame, but it is not completely at the top position. Since the navbar is sticky, I'm guessing…
mojaomi
  • 115
  • 6
2
votes
1 answer

How do I make assertions consistently wait until a turbo frame has been updated?

My system tests are experiencing a race condition leading to inconsistent test results. Sometimes the turbo frame is updated before my assertion (test passes) and sometimes afterward (test fails). View:
<%= form_with…
Eric Mathison
  • 1,210
  • 10
  • 16
2
votes
0 answers

Identical link_to tags, one uses turbo the other doesn't

I have 2 identical link_to tags, that produce indentical html, used in 2 different views. However one sends a turbo request, while the other doesn't (I believe). My goal is for both to use turbo to load a view. The one using turbo works as expected,…
2
votes
0 answers

Proper set-up for using import maps with Rails 7 and turbo

Following an bin/importmap pin pixabay-javascript-autocomplete the importmap.rb has the proper entry and the header of the page does have in the script tag for the imports json block: "pixabay-javascript-autocomplete":…
Jerome
  • 5,583
  • 3
  • 33
  • 76
2
votes
0 answers

What is the best way to test Turbo Rails with Rspec?

I would like to have a good example on how to test Turbo with Rspec. I copied a piece of turbo that I want to test. Todo view:
  • "> <%= turbo_frame_tag dom_id(todo) do…
  • Chiara Ani
    • 918
    • 7
    • 25
    1 2
    3
    13 14