Table: RailsNotes
User: dreamable
Created at: 2023-05-09 21:56:21 UTC
Updated at: 2023-05-09 21:56:43 UTC
Reference:(Table ID 3, Record ID 53)

标题 :
Rails 7 undefined method `javascript_pack_tag'
笔记 :

迁移项目到Rails7,遇到一下问题:

undefined method `javascript_pack_tag'
<%= javascript_pack_tag 'application', 'data-turbo-track': 'reload' %>

根源: javascript_pack_tag is a Webpacker-specific method, so unless you're using Webpacker, you can't use it.

Rails中webpacker被 importmapped Hotwire取代

正确的做法是

    <%= javascript_importmap_tags %>