I cancelled my Hey email accounts

Yesterday I cancelled two @heyhey email accounts. It’s really hard to figure out what the two fellas at the top were thinking by implementing their new company policy on political/social discussions. It’s especially bizarre given the outspoken nature of both the founders. Unfortunately, it’s becoming apparent today that Rails is going to be an innocent … Continued

Stop Turbolinks from adding multiple script tags with nonce

If you’re using a Content Security Policy (CSP) in your Rails app you probably already know how finicky things can get. One common annoyance you may run into is an issue where a script tag is added to the <head> over and over again with each page request. It’s no bueno, but there’s a way around it. THE SCENARIO … Continued

Using private NPM packages with Rails, Heroku and Github

There are numerous reasons why you’d want to leverage the following setup. However, I’m going to be using a trivial example of sharing some CSS styles across different Rails apps via an npm package. That npm package will be private and hosted on GitHub. After we install the package into our Rails project via Yarn, we’ll … Continued

How to handle time in Rails

Handling time is a doozy. It’s not necessarily a problem that is specific to Rails either. It’s just hard. There are a thousand things to consider. I want to help you get an idea of what a reasonable setup might look like and let you go from there. The following steps are meant to be … Continued

Cleaning up figures in Action Text

Action Text and Trix are great and give you an immense amount of power right out of the box. That being said, I didn’t like a bit of the styling for both the presentation of the figure to the user and in the editor. So let’s fix it! ASSUMPTIONS You’re using Bootstrap 4 You’re starting from a fresh install of … Continued

Customizing the Trix toolbar

I recently added the Trix Editor to a Rails app I was working on and quickly found that I was going to need to do some modifying to the toolbar buttons. Out of the box Trix only gives you an h1 button for creating headers and the site I was building was already populating an h1 tag via a separate field. … Continued

A gotcha with Active Storage and Cloudflare

Rails 5.2 introduced Active Storage and it’s pretty awesome. I’d used paperclip from the @thoughtbot folks for a long time, but file uploading is a requirement for just about any site these days so it might as well be part of the core. Now it is. Well, if you happened to implement Active Storage into your Rails app and happen to … Continued

Categories in a Rails App

Categorizing things in a Rails app is a common need, but it’s a non-trivial lift to get it all implemented. Database relationships need to be right. How in the world should you set up your forms? What’s going on in my controllers? I’m going to do my best to show you how I implement categories. Here’s our … Continued

Debugging in RubyMine with Rails 5.2

If you’ve upgraded to Rails 5.2 and are using RubyMine’s debugger you might notice that breakpoints aren’t working as they should. For me, they would only work in views, but controllers and models wouldn’t stop anything. Turns out the problem is the inclusion of the Bootsnap gem in Rails 5.2. Bootsnap is awesome so you probably want … Continued

Custom validation in Rails

Here’s a little trick I like to do when I’m addressing validations in my models. Let’s say you have a standard Post model. It might look something like the following. If you’re like me and prone to ideas popping into your head at inopportune times then you probably only have a few seconds to jot down an … Continued