Questions tagged [hotwire-rails]

Hotwire-rails is a collection of front-end tools for Rails available since Rails 6 and enabled by default in Rails 7. Use the [Hotwire-rails] tag for questions about Stimulus, Turbo Drive, Turbo Frames and Turbo Streams and especially their usage in Rails. This tag is not for turbo-links (unless the question is about updating to Hotwire). Also be aware that Hotwire and its components are sometimes used outside of Rails.

See also:

228 questions
3
votes
1 answer

How to convert minitest create test to accommodate turbo_stream?

In minitest, prior to Hotwire, a create test might look like the following: test "should create user" do assert_difference('User.count') do post users_url, params: { user: valid_params } end assert_redirected_to users_path …
hellion
  • 4,602
  • 6
  • 38
  • 77
3
votes
2 answers

Hotwire not updating list with projects

I have Hotwire setup in my Rails app, but it doesn't update the index view with projects. I have a simple projects view:
    <%= turbo_stream_from "projects" %> <%= turbo_frame_tag…
John
  • 6,404
  • 14
  • 54
  • 106
3
votes
1 answer

Finding the current URL or "main" controller from within a Turbo Frame in Rails

I have a Turbo Frame on my page which uses the src attribute to load in /chats/. Within this frame I want to be able to know whether the main page is using the show action of the groups controller, i.e. the URL of the page is at…
tsvallender
  • 2,615
  • 6
  • 32
  • 42
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
2 answers

Rails: turbo-frame with src requested interpreted as format.html

I've noticed this strange behavior of turbo frames loading lazily via src attribute setting: nav = turbo_frame_tag 'primary_menu', src: primary_menu_path : def primary_menu : respond_to do |format| : format.turbo_stream > : …
BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
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
3
votes
1 answer

Hotwire Turbo does not replace turbo-frame

I have a form
KingOfCoders
  • 2,253
  • 2
  • 23
  • 34
3
votes
1 answer

Having nested elements with the same controller

So i have this case, where i have a list that is hidden by default, and when you click a button it toggles the visibility. this is my controller import { Controller } from "stimulus"; export default class extends Controller { static targets =…
Ahmed Khattab
  • 2,645
  • 2
  • 13
  • 19
3
votes
2 answers

Rails Hotwire doesn't update the page

im familiar with ROR and i want to use new Hotwire-Rails in my project. I't is fine when i create posts. But when i updating/deleting posts nothing happened at the page. Can you please tell me where im doing wrong? And finally i want make a sound…
3
votes
0 answers

Update Rails to Hotwire Gives a 304

I've updated a Rails '6.0.3' app to use hotwire-rails rather than turbolinks and am getting a 304 for the response with no update to the view within the turbo_frame_tag I created a new Rails app from scratch and implemented hotwire successfully so…
vladiim
  • 1,862
  • 2
  • 20
  • 27
2
votes
1 answer

How to autoscroll when a new partial is rendered by turbo frame?

i'm having a little trouble trying to force a scrolling with javascript when a new partial are rendered by turbo-frame, the page have an small form, and when the button are clicked, he triggers an event who render a new form, and when a new form are…
2
votes
1 answer

Turbo-rails not functioning in production

My app: ruby 3.1.2 rails 7.0.4 importmap-rails 1.1.5 turbo-rails 1.4.0 In development, everything behaves as expected, but in production (Ubuntu 22.04) NOTHING turbo-related seems to work: Links always trigger a complete page reload turbo-confirm…
Giuseppe
  • 5,188
  • 4
  • 40
  • 37
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…