Posts about my adventures in coding


Honeybadger deployment tracking for Rails with Kamal and Doppler

I recently signed up for Honeybadger to help with monitoring and error tracking for my Rails app. It’s easy to set up (just add a gem!) and they have a great free tier for small projects. Besides error tracking, Honeybadger also offers a simple way to track each time you deploy a new version of your  app. 

 This post explains how to set up the deployment tracking specifically for a Rails app that uses Kamal for deploying and Doppler for secret management (if you need help setting up Doppler with Kamal, see my previous post). After signing up for and installing Honybadger, there are only two steps:

  1. Add your Honeybadger API key to your Doppler project

  2. Set up a Kamal post-deploy hook to send a deploy notification to Honeybadger

Continue reading…


Setting up a Rails 8 + Kamal app with Doppler Secrets

I recently started working on a new personal Rails project and was eager to try out Kamal and a secret manager called Doppler. I heard about Doppler on one of the Rails-related podcasts and loved what they had to say. I decided to use it with my app so that all my secrets would be centralized, easier to manage, and there would less risk of accidentally committing something to Github. 

Doppler’s CLI tool also lets you run commands with secrets injected directly from your secret store so that they won’t show up in the shell history. They have a generous free tier, as well!

Best of all, Kamal provides an adapter for Doppler so that you can easily read your secrets directly into the .kamal/secrets file and inject them into your app as ENV variables. Below I’ll explain how I got everything set up for development and production. I'm also planning to write another post on how I set up my app to deploy using Kamal soon.

Continue reading…


Understanding Rails Polymorphic Associations: A Case Study

I recently got to implement a polymorphic table in Rails at work. I’ve read about polymorphism a few times in books or blogs, but I never quite understood it. Having a real-life situation to apply the concept to at work, along with some conversations with my team’s lead engineer finally made it click!

A lot of the examples in other articles and in even in the documentation are somewhat contrived, so I’d like to share what I did on the job as a real-world mini case study in hopes that this helps someone else.

Continue reading…


Sidekiq’s sidekiq_retries_exhausted hook

sidekiq_retries_exhausted is a Sidekiq hook that you can use to do something after Sidekiq has used up all of its retries but the job still failed. It’s a good way to make sure you send a failure notification or log an error that might be causing the job to fail instead of it just failing silently.

In the worker, you can set a specific number of retries if you want with sidekiq_options retry: <some_number>. The default is 25 times.

Continue reading…



QR Code Reader on Rails

Intro and getting started

I recently had to implement a QR code reader in Rails at work and in this article, I’ll take you through how I did it by creating a demo featuring two different ways of handling scanned QR codes: One simply scans a QR code and displays the scanned data on the screen and the other sends the QR data to a Rails controller for processing.

Let’s get started right away! We’ll do so by creating a new Rails project:

rails new qr-code-reader-demo

Next, we’ll install a JavaScript library that will allow us to scan QR codes with a video camera on a phone or computer.

Continue reading…







Debugging Google Cloud Storage CORS errors in Rails 6 Action Text (direct upload of images)

I recently tried out using Rails 6’s new Action Text feature for a simple blog page. One thing I like is about it is how it lets you drag and drop in multiple images and then automatically places them into a nicely formatted “gallery” layout.

When images are placed into the Action Text editor, it performs a direct upload of each image into your storage location via JavaScript. Depending on what you are using for image storage, you may run into some problems caused by CORS (Cross-origin resource sharing) errors.

Continue reading…


Sending Emails in Rails with Action Mailer and Gmail

In this post, I will be setting up a mailer in Rails that will send out an email to the website owner when a customer submits an order. (I was using Rails 6 but this should also work in Rails 5).

The steps:

  1. Set up a mailer with rails generate mailer

  2. Create email templates (views)

  3. Tell the appropriate controller action to send the email

  4. Set up an email previewer

  5. Configure the mail settings for Gmail.

  6. Set up tests

Continue reading…


I18n for Rails: Set-up for Using Locales from URL Params and Basic I18n Usage

Setting up I18n for Ruby/Rails apps is fairly simple, but as a beginner, I often run into some hiccups with the configuration (and trying to decipher what exactly is being said in the Rails Guides and other people’s blogs). As a reference for myself and hopefully other developers who are just starting out, I’m going to document the steps I take for using I18n in my apps.

Continue reading…



Subscribe to read future posts in your inbox (or grab the RSS feed)