0
// app/javascript/application.js
import "@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/importmap

pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_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/[email protected]/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")
  end
end

What is the problem with the turbo?

1

1 Answer 1

0

Try below one:

<%= link_to "Sign Out", destroy_user_session_path, data: { "turbo-method": :delete } %>

Hope it helps!

1
  • Nope. Your solution didn't solve the problem. I had to change link_to to the form, something like: ``` = form_with url: destroy_user_session_path, method: :delete, local: true, data: { turbo: false} do = submit_tag 'Sign Out ``` And only then was the turbo turned off.
    – Steven
    Commented Jul 18 at 15:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.