Blog
Tagged with: rails
Using Clearance with Rails 7
For some time now, the Ruby on Rails community has anointed Devise as its preferred authentication solution. Iâve repeatedly used Devise, and itâs great. Not all of us have the time or expertise to roll our own auth, so itâs fantastic a solution exists that is widely adopted. It was only natural that Iâd reach ...
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.
Letâs assum...
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, ...
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 more conceptual than a line-by-...
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!
- Youâre using Bootstrap 4
- Youâre starting from a fresh install of Action Text ...
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 modifications 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. Therefore,...
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 littl...
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 ap...
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 aweso...
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 idea b...
Blog Categories
About These Posts

My blog primarily contains writings about my work on computers, but I occasionally mix in fun life stuff. I am, at best, a mediocre writer, but I like doing my part to give back to the community. Feel free to contact me if you have specific something to chat about. See you around!