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
0
votes
1 answer

How can I refresh all the cookies, token and session after logout calling API using Rails Hotwire

I am working on a project which is done in Rails Hotwire where devise gem has been used for authentication and, in frontend Stimulus.js has been used. Instead of using link_to , I want to write an API with delete method, to refresh like: cookies,…
0
votes
2 answers

Does installing hotwire in a rails project require Javascript?

My OS is Linux and my distribution is debian-bullseye. My ruby version is 3.1 and my rails version is 7. I created a rails project rails new chat --skip-javascript cd chat/ I installed hotwire bundle add hotwire-rails rails hotwire:install And I…
Chiara Ani
  • 918
  • 7
  • 25
0
votes
2 answers

My Jquery files are only loading on Refresh page rails 7

My Jquery files are only loading when page is refreshed. But when I remove (import "@hotwired/turbo-rails") from application.js It works normally. But removing "@hotwired/turbo-rails" causing other issues. Anyone please help.
0
votes
2 answers

Turbo Stream broadcast_replace_to is removing the turbo_frame_tag

Code snippets: application.html.erb: <%= turbo_stream_from current_user, "counter" %> <% if current_user%> <%= render partial: "users/counter", locals: { user: current_user } %> <% end %> users/_counter.html.erb: <%= turbo_frame_tag…
septerr
  • 6,445
  • 9
  • 50
  • 73
0
votes
0 answers

Passing a Rails controller defined local variable into a Turbo Frame Tag

I am a super newbie to rails but I am defining a local variable (a css class) and passing it to this partial render(partial: 'calendar_inventory', locals:{klass: params[:select]}) Inside my partial I have a pagination occurring:
0
votes
1 answer

turbo confirm with rails 7.0.3 not working on Github Codespaces?

There are already answers on how to make the confirm button works with DELETE in Rails 7 as Rails 7 now prefer Hotwired Stimulus than Turbo. They are answered here: How to call confirm prompt using button_to in Rails with Turbo. The accepted answer…
0
votes
1 answer

ActiveRecord::RecordNotFound (Couldn't find Batch with 'id'=undefined) with Rails 7 Stimulus & nested resources

My Rails 7 app uses the following models: Batch model, has_many tasks Task model, belongs_to a batch Resources are nested as follows: resources :batches do resources :tasks end The task model has a completed attribute which is a boolean. I am…
Thibaud Clement
  • 6,607
  • 10
  • 50
  • 103
0
votes
1 answer

Turbo_stream work from controller, but not from view

I'm working on a rails 7 app with hotwire. I have a form modal, when subimited, turbo should remove html from modal and show flash message. When i put my turbo code in my controller i works: # emails_controller.rb def forward service =…
Sonfaya
  • 27
  • 6
0
votes
1 answer

Turbo and content_for - Rails

I'm trying to load a javascript only on a certain page. For that I'm using <%= yield(:head) %> in the and the following on the page: <% content_for :head do %> <%= javascript_import_module_tag "foo" %> <% end %> This works when clicking on…
derschiw
  • 120
  • 5
0
votes
2 answers

RoR Rails 7 using Turbo to Update a partial on button click

Help! I'm relatively new to Ruby on Rails and now I'm attempting to use Rails 7 with Turbo and Stimulus to update a partial on my web page. I have buttons on a page within a partial (call it _home.html.erb). When clicked I'd like them to replace…
epurdy
  • 151
  • 1
  • 12
0
votes
1 answer

How can I create a button which adds fields to a Rails form

I have a form in Rails which uses fields_for to accept nested attributes: <%= form_with(model: @combat_tracker, url: form_url) do |f| %> … <%= f.fields_for :zones do |zone| %>
<%= zone.text_field :name %> …
tsvallender
  • 2,615
  • 6
  • 32
  • 42
0
votes
1 answer

Turbo.remove() not working , while turbo.update still performed

i'm building an app with rails 7 and hotwire. I have a div with a invite message, when the invitation is declined, 2 actions should be triggered: I- Update my flash messages to display 'you declined the invitation' in my toaster (Working) II- Remove…
Sonfaya
  • 27
  • 6
0
votes
1 answer

Ruby on rails turbo current user access

index.html.erb <%= turbo_stream_from "posts" %> <%= turbo_frame_tag "posts" do %> <%= render partial:'posts/post', collection: @posts, as: :post %> <% end %> _post.html.erb <% if Current.user.id == post.user_id %>
Levi
  • 1
0
votes
0 answers

Rails TurboStream sync polymorphic views

iam working on a task that make appointments that will show on calendar in which the appointment's position be calculated by its start_time and end_time, iam using Rails7 + TurboStream to sync (real time) the appointment(create/update/destroy)…
Lam Phan
  • 3,405
  • 2
  • 9
  • 20
0
votes
0 answers

Rails 7 ActiveStorage DirectUpload to S3 presigned_url return 403

So I was able to set up the direct upload on the view, and send a request to the s3_presigned_url that I've created. The problem is: I'm getting a 403 Forbidden. My main guess on the issue is about the request method that is being made, with is a…