roadmap icon indicating copy to clipboard operation
roadmap copied to clipboard

Migrate from Rails UJS to Turbo

Open benjaminfaure opened this issue 1 year ago • 0 comments

Rails UJS is deprecated and will be removed in Rails 7.2 : https://edgeguides.rubyonrails.org/7_2_release_notes.html#action-view-removals

It is used in a lot of places, mainly to create links & buttons that uses POST or DELETE http methods. Here's an example with the sign out link : https://github.com/DMPRoadmap/roadmap/blob/fc047ac0ae1b10f9fd451909e11a2d31e50b3ada/app/views/layouts/_signin_signout.html.erb#L39

An upgrade guide is available here and is quite simple but a lot a views require changes as the data attributes needs to be changed from data-method="delete" to data-turbo-method="delete".

The above example would be : <%= link_to '<i class="fas fa-right-to-bracket" aria-hidden="true">&nbsp;</i>&nbsp;'.html_safe + _('Logout'), destroy_user_session_path, data: {turbo_method: :delete}, class: 'dropdown-item' %>

benjaminfaure avatar Jun 18 '24 07:06 benjaminfaure