devise-otp 2.0 released
The OTP plugin for Devise I help to maintain goes 2.0 this week. Here is what’s new and how to upgrade.What’s newWe tried to address a couple of things in this release, mainly support for lockable...
View ArticleInvoicePrinter 2.5 with QR images and Ruby 3.4 support
Today I released a new version of InvoicePrinter, my Ruby library for generating PDF invoices. Here’s what’s new.New featuresI finally implemented last feature I had in mind, QR code images. I decided...
View ArticleRunning JavaScript after a Turbo Stream renders
Turbo comes with turbo:before-stream-render but unfortunately doesn’t ship with the equivalent turbo:after-stream-render. Here’s how to run JavaScript after the stream renders.Why we need thisIf you...
View ArticleRunning interactive sessions with Kamal
How to connect to a container on a server managed by Kamal and run an interactive session?Interactive server actionsKamal comes with a kamal server exec to execute a single command on the server. If we...
View ArticlePredownloading embedding models in Rails with Kamal
If you are building AI-powered applications in Ruby on Rails, you might have come across Informers or Transformers.rb gems for transformer inference. Here’s how to improve the production deployment of...
View ArticleCombining multiple sitemaps with a sitemap index
What if we need to combine multiple sitemaps for a main domain or subdomain? Here’s how to do it by creating sitemap index.Sitemap indexLet’s say our site has a regular sitemap.xml and a...
View ArticleSetting up Cloudflare R2 buckets for Active Storage
Rails comes with a built-in support for saving and uploading files to S3 and S3-compatible storage services in Active Storage. Here’s how to set up Cloudflare R2.Cloudflare R2To start using Cloudflare...
View ArticleAdding button loader to Turbo-powered forms
Turbo is a great way to build user interfaces, but most Turbo forms have to wait for the server response. Here’s how I am adding a small loading spinner to the submit buttons to improve the UX.Submit...
View ArticleAuto-saving Rails forms with Turbo Streams
Here’s how to implement autosaving for inline input fields the Hotwire way.Autosaved formsWhat’s autosave? Autosaving is saving a user input automatically on changes, lost focus or after an interval of...
View ArticleBusiness Class 2.0 with Rails 8, Pay 8, Solid, Kamal 2, and fancy generator
The Ruby on Rails template Business Class gets a whole new edition. Rails 8, new licencing, and improved CRUD generator.Business Class 2.0The new Business Class is built on top of Rails 8, Pay 8, Solid...
View ArticleExtending Rails authentication generator with registration flow
Rails 8 comes with a built-in authentication generator. However, it doesn’t yet come with registrations. Here’s how to add them.Rails auth generatorTo generate authentication scaffold, run:$ rails...
View ArticleCannot connect to the Docker daemon after switching to OrbStack
Switching from Docker Desktop to OrbStack and stuck at Docker daemon error? Here’s how to fix itWhen Kamal cannot connect$ kamal build ERROR: Cannot connect to the Docker daemon at...
View ArticleHow to use a remote build server with Kamal
How and when to create an external build server for your Kamal deploys?Remote build serverWhat’s a remote builder anyways? Kamal will build your Docker images locally by default (on your laptop or...
View ArticleHow does Kamal deploy to multiple hosts
How does Kamal deploy to multiple hosts at once? And how to configure it?SSHKitKamal is built around SSHKit which provides Kamal with the SSH connections to issue remote commands. Through out the Kamal...
View ArticleTest Driving Rails, 1st edition is released!
I am releasing my third book today. This time about Rails-native testing!IdeaI am a big fan of Rails defaults and especially those for testing. Minitest and fixtures rock! But all I ever see are posts...
View ArticleUsing non-root users in Kamal
Kamal gives us an option to connect with a non-root user, but how can we create it?Creating a non-root userIf you use cloud VM providers like Hetzner or Digital Ocean, your virtual private server with...
View ArticleSubclassing STI models in Rails
Here’s a short tip on opting out a specific model from Single Table Inheritance (STI).Imagine a Vehicle model which is implemented using STI and extented with a type parameter to Sedan and Wagon...
View ArticleShow all running apps on the server with Kamal
Kamal 2 can deploy multiple apps on a single server so it’s easy to lose track of what’s deployed. This alias will fix it.To see all running apps on a server we need to query Kamal Proxy:$ ssh...
View ArticleUnderstanding Kamal proxy roles
Kamal’s configuration comes with one primary proxy role to accept HTTP traffic. Here’s how to think about proxy roles and how to configure others.Kamal rolesRoles are a Kamal way to split application...
View ArticleA closer look at Rails force_ssl and assume_ssl
Rails comes with a built-in support for SSL in form of config.force_ssl. But what does it exactly do?SSL middlewareThe force_ssl directive adds the ActionDispatch::SSL middleware layer which is a Rack...
View Article