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
2
votes
0 answers

How to set up Rails UJS along with Turbo?

I'm confused as to exactly what I need to do to run my old jQuery snippets and Rails UJS along with Turbo. DHH added this PR in June that was supposed to improve compatibility, but it lacks details on exactly how the setup should work. I still have…
dwayne
  • 118
  • 7
2
votes
1 answer

How to insert a form for a new record using Turbo/Stimuls?

The future of Rails seems to be moving away from UJS and towards Turbo and Stimulus. But, some features seem to require more code and more work vs old-school UJS. For example: To insert a form inline that would allow the creation of a new record…
hellion
  • 4,602
  • 6
  • 38
  • 77
2
votes
0 answers

Cannot submit form drawn by Rails Turbo Frame response

A form inside a turbo_frame is blocked from being submitted a second time. Both the current page and the form action are the same path. I see forms now have to redirect to a new location or return an error code: turbo/pull/39. I have a form on every…
rigyt
  • 2,219
  • 3
  • 28
  • 40
2
votes
1 answer

Rails Turbo Removes Hubspot Injected HTML on page redirect

I'm using a Hubspot chat bot in a rails app that's setup with Hotwire & turbo. When the page is initially loaded a Hubspot script will inject some html into the body of the page which contains the chatbot. Once any redirect happens the body is…
projectmind
  • 540
  • 4
  • 17
2
votes
1 answer

Adding stimulus and importmaps to an existing Rails 6.1 app

I've got a Rails 6.1 app which has been upgraded from Rails 4 -> 5 -> 6, so it's mature. It still uses asset pipeline and with the future of Rails 7.0 I'm going to keep it that way. I wanted to start using stimulus + importmaps, so I've followed…
map7
  • 5,096
  • 6
  • 65
  • 128
2
votes
1 answer

Rails + Hotwire: Why does my link disappear when I click it?

I'm trying to incorporate Hotwire/Turbo into an existing Rails application. I've added turbo frames to a simple edit page, but now when I click my back button, it disappears instead of taking me to target page. The link is a simple link_to "Back",…
aidan
  • 1,627
  • 17
  • 27
2
votes
0 answers

Activate script tags from turbo frames - Rails

When we return turbo frames in post request sometimes it is esential run javascript for example if I am calling a resource to update, there are two possible cases when it saves sucessfully then close the modal When it is not saved then show…
Vishal G
  • 1,521
  • 11
  • 30
2
votes
2 answers

In a Hotwire/Rails app, how to force a form helper to accept only text/html?

I've incorporated Hotwire into my latest Rails 6 app. The Hotwire/Turbo portions are working great, but I have a plain user form that I don't want to use Hotwire/Turbo for. Currently, all form submissions are hitting format.turbo_stream {} in my…
aidan
  • 1,627
  • 17
  • 27
2
votes
2 answers

pass a function to stimulus

I have been using stimulus for my latest project, and I like how I can factor and modularize the code into small reusable parts. However, there are times when generating a new controller and putting it as an element attribute is a bit cumbersome…
quetzalfir
  • 528
  • 7
  • 22
2
votes
1 answer

How to define the way instance model should be rendered in Rails 6

I'm using Hotwire and devise User on a Rails 6.0.3.6 app. I add this broadcast for Users class User after_create_commit { broadcast_append_to 'users' } end Then when a User is created it goes through his partial (users/user) where I am trying…
1
vote
2 answers

Expect a Turbo Stream Broadcast in an RSpec Request Test

I'm writing a request test in RSpec and in the course of the controller path I am testing, the application sends out two turbo stream broadcasts. I have not been able to get the broadcast_to expectation to work in this case. I feel I am close, but I…
crespire
  • 33
  • 1
  • 7
1
vote
0 answers

fetchOptions body is null on form submit with stimulus.js : Uncaught TypeError: Cannot read properties of null (reading 'set')

I'm trying to create a dynamic search with Ruby on Rails using Turbo and Stimulus controllers. I followed a great tutorial (typeahead-search-tutorial) and was able to get this working seamlessly as an independent (simple) app. Now I'm attempting to…
1
vote
0 answers

Testing Action Mailer Count in Rails 7 with Hotwire and Turbo Stream (Sytem test case using capybara)

When using Rails 7 with Hotwire and Turbo Streams, and not utilizing Rails UJS, we encounter an issue when creating system test cases for an action that includes a button with data-turbo: true and turbo-method attributes, combined with HTTP verbs.…
1
vote
0 answers

Rails turbo_stream replace options_from_collection_for_select from turbo_stream.erb

I'm trying to replace the value of the dropdown though the turbo stream. through js request we can do as views/projects/filter_units_by_organization.js.erb $('select#project_unit_id').html('<%= j options_from_collection_for_select(@filtered_units,…
1
vote
1 answer

Loading uppy with Rails 7 and stimulus and importmaps

Is it doable to load Uppy into a vanilla Rails app via the Rails 7 importmaps? If you end up pinning @uppy/core, you get a lot of dependencies added to your importmap file: bin/importmap pin @uppy/core ...but when you try to access it via a…