Modern Rails

Articles, tips and guides about modern Ruby on Rails development.

A microphone talking into a microphone

Using the OpenAI Text-to-speech API with Rails

Learn how to create audio versions of your blogposts with the new OpenAI TTS API. We’re going to use Callbacks, ActiveJob and the ruby-openai gem.

November 30, 2023 · Niklas

Deploy a website with kamal-skiff

Using GitHub Container Registry, kamal-skiff, Hetzner and Cloudflare to deploy a simple static website

September 29, 2023 · Niklas

OpenAI transcription API and ActiveStorage analyzers

Connecting the OpenAI transcription API and ActiveStorage analyzers to transcribe audiofiles with AI

August 26, 2023 · Niklas

A demo of Rails and the OpenAI Chat API

Using the OpenAI Chat API, Server-Sent Events and Rails to generate blogposts automatically

August 15, 2023 · Niklas

Generated columns with ActiveRecord

I looked at the recent changes of Rails and Activerecord and spotted an interesting entry: Support for generated columns in PostgreSQL. In this post I’ll show an example how to use generated columns with Rails 7 and PostgreSQL. Let’s create a new table Humans with the stored generated column bmi_stored: class CreateHumans < ActiveRecord::Migration[7.0] def change create_table :humans do |t| t.integer :weight_in_kilos t.integer :height_in_cm # Generated columns bmi_sql_function = 'weight_in_kilos / (height_in_cm::float / 100) ^ 2' t....

Niklas