Tutorials
How to save a recently viewed list of pages with Stimulus and localStorage
Creating a "recently viewed pages" list can significantly enhance the user experience by providing easy navigation and a history of recently accessed content. Seeing how we are already using Rails, we are going to leverage Stimulus. Also, instead ...
Structure Your ERb and Partials for more Maintainable Front-end Code in Rails
When should we use a partial or a helper–or a partial rendered using a helper? Which elements should be extracted into partials or helpers? When can we use a simple helper and skip the partial file? When should we use the built-in tag helpers inst...
Conditionally render a Turbo Frame shared between multiple views
The Turbo Frames API requires that a request made from within a turbo-frame must receive a response containing a corresponding turbo-frame of the same id.Because Rails encourages the reuse of partials and views, this can lead to situations where y...
Build a modal form with Rails, Turbo, and the dialog element
Turbo is great because it allows us to enhance the server-rendered behavior that Rails already excels at. We can build our feature in the traditional way, using familiar Rails techniques: model, route, controller, and view. Once the basics are in ...