rails: Turbo not loaded when following 7.0.1 tutorial
Steps to reproduce
Following Getting Started with Rails in the selection on “deleting an article”. Clicking the destroy link does nothing, just produce a GET-request for the article itself. Look at the generated HTML, turbo is never loaded. Adding in <%= turbo_include_tags %> in app/views/articles/show.html.erb fixes it.
Expected behavior
Clicking ‘Destroy’ on the article page removes the article by sending a DELETE-request, with a confim dialog beforehand.
Actual behavior
Turbo is never loaded, so clicking ‘Destroy’ simply sends a GET-request to the article.
System configuration
Rails version: 7.0.1
Ruby version: ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]
On Arch, I also had some issues with #44143
Is there anything I can do to make sure Turbo is being included without having to remember to type turbo_include_tags all the time?
Also, stylesheets appear not to be loaded either, as my app doesn’t correspond to the screenshot in the guide.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 16 (2 by maintainers)
I was facing the same issue on a project initialized with the first release of rails 7.0.0. After upgrading to 7.0.1 on the same project, the issue still occurs. The workaround of adding
<%= turbo_include_tags %>fix the issue.Like @Rik-de-Kort, I’ve ended up recreating a new project from scratch and the issue is now solved.
same issue with the start up guide, when click
destroylinkruby -v ruby 3.2.2
rails --version Rails 7.1.1
<%= turbo_include_tags %>finally fixed the problemI’m on Rails 7.0.5 and
<%= turbo_include_tags %>finally fixed the problem for me.@UmairAhmedImran checking how to handle the configuration I used with this rails installation:
--skip-bundle. Don’t know yet if it’s reversible at all. But, why that argument stopped the generation of the directories and files?Found this: StackOverflow - Ruby on Rails - javascript(s) folder and application.js missing and helped a little.
for now, it seems to work.
@test0n3 including
<%= turbo_include_tags %>will work but later on it can cause more problems. So I will recommend to have rails new <application-name> to run properly. Check the image below on left side I created the application with --skip-bundle and after creating initial folder I run the bundle command and it does not include app/javascript. But when I create a new app without any tags it created app/javascript and the code run smoothly without using any<%= turbo_include_tags %>Also
rails newalways ends like thisI don’t think the
<%= turbo_include_tags %>solution should be recommended because it shouldn’t be needed at all. Generally, every issue I’ve seen where people are having issues with Turbo not loading is due to some error while runningrails new. Ifrails newruns without errors,import "@hotwired/turbo-rails"is added toapplication.jsand Turbo will be loaded.If you (or anyone) can reproduce an error while running
rails new, you should absolutely open an issue detailing the steps and the full log of runningrails new. Otherwise, I don’t think there is anything actionable here.