Cesare Ferrari

July 26, 2022

Testing Hotwire: creating a new document

In the previous post I started creating a Document model, to represent a document upload file. The model has a name, a description, and will have an attached file upload feature in the final version. I have shown how to test and create a functionality to view details of a document by clicking on a list of existing documents. In this po...
Read more
July 25, 2022

Testing Hotwire

Let’s see how to test views that have Turbo frames updated with Hotwire. I am now generating a model in my Rails application. The model name is Document and it represents a document. Ultimately, the document will have an actual uploaded file, but for now, the Document model will only have a name and a description. rails g model Documen...
Read more
July 22, 2022

Rails Turbo frames: how to update a different frame

We have already seen that how to update a Turbo frame by clicking on a link. As long as the link is inside a turbo-frame element and the server response also contains a turbo-frame with the same id, Turbo Drive will update the first turbo-frame with the content of the second one. But how do we update a different frame in the originatin...
Read more
July 21, 2022

Working with Turbo Frames in a Rails application

Turbo frames let you divide an HTML page into discrete sections that can be updated independently from the rest of the page. These sections are represented by turbo-frame custom HTML elements with unique id attributes. To create turbo-frames we use the turbo_frame_tag helper in a Rails view with a syntax similar to this: <%= turbo_fram...
Read more
July 20, 2022

How to disable Turbo Drive in a Rails application

Turbo Drive intercepts link clicks and form submissions and generates Ajax calls to speed up page refresh. It comes enabled by default in a Rails 7 application. Sometimes, though, we may be in a situation where we need to disable Turbo Drive in order to force a full page refresh when we click a link or submit a form. To disable Turbo D...
Read more
July 19, 2022

What is Turbo Drive

Turbo Drive is a technology implemented in Ruby on Rails that speeds page loads. It does so by intercepting link click and form submission events and converting them to Ajax requests to the server. It then takes the HTML responses returned by the server as a result of these requests and updates the <body> of the page in the browser, so...
Read more
July 13, 2022

Connecting to localhost with a phone to view my Rails site in development

Problem: I want to view a Rails website during development on localhost using my phone browser. Bind Rails to IP address Start a Rails server binding to . The server will listen to port 3000 by default (but it can be changed with the -p flag): rails s -b => Booting Puma => Rails application starting in developme...
Read more