Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4609

Rails: problem with "@hotwired/turbo-rails" and redirects

$
0
0
// app/javascript/application.jsimport "@hotwired/turbo-rails"import "controllers"import "trix"import "@rails/actiontext"import Rails from "@rails/ujs"Rails.start()
# config/importmap.rb# Pin npm packages by running ./bin/importmappin "application", preload: truepin "@hotwired/turbo-rails", to: "turbo.min.js", preload: truepin "@hotwired/stimulus", to: "stimulus.min.js", preload: truepin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: truepin_all_from "app/javascript/controllers", under: "controllers"pin "trix"pin "@rails/actiontext", to: "actiontext.js"pin "@rails/ujs", to: "https://ga.jspm.io/npm:@rails/ujs@7.0.4/lib/assets/compiled/rails-ujs.js"

For example in code I have:

= link_to 'Sing Out', destroy_user_session_path, method: :delete, data:{turbo: false}

when I clicked Sing out i.e. new views coming from root_path are added. Turbo: false doesn't fix.

What I mean:

Before action

After Action

I can turn off turbo(like below) and then redirect work correctly:

// app/javascript/application.js//import "@hotwired/turbo-rails"import "controllers"import "trix"import "@rails/actiontext"import Rails from "@rails/ujs"Rails.start()

I also tried something like below, but it didn't help:

class ApplicationController < ActionController::Base   ..................................................................  def after_sign_out_path_for(resource_or_scope)    disable_turbo    root_path  end  def disable_turbo    response.set_header("Turbo-Frame", "_top")  endend

What is the problem with the turbo?


Viewing all articles
Browse latest Browse all 4609

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>