DMPRoadmap / roadmap

DCC/UC3 collaboration for a data management planning tool
MIT License
106 stars 109 forks source link

Migrate from Rails UJS to Turbo #3429

Open benjaminfaure opened 5 months ago

benjaminfaure commented 5 months ago

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' %>