Nicholas Shirley
  • Home

Nicholas Shirley

8 posts •
Rails

Verify That an ActiveRecord Object has at Least One Attribute

Rails ActiveRecord callbacks make validation a breeze, but what happens if you want to verify that a record has at least one attribute present, but you don't care which attribute it is? This

  • Nicholas Shirley
3 min read
Productivity

Learning Vim, the Long Way

Vim has changed the way I work in a massive positive way, but I spent over a year giving up and coming back before it finally stuck. This is what worked for me.

  • Nicholas Shirley
5 min read
Rails

Re-associate ActiveStorage attachments after changing a table name

Sometimes you have to change a table name. When you do, don't forget to update ActiveStorage relationships otherwise your files will be orphaned.

  • Nicholas Shirley
1 min read
Rails

Deleting ActiveStorage Attachments From the Controller, 3 Ways

ActiveStorage in Rails 5.2 is awesome, but where do handle deleting attachments on the controller? Here are some possible options.

  • Nicholas Shirley
4 min read
Rails

Retrieve Associated Parent Attributes from Child Record in Rails

Calling attributes of associated records isn't "directional". Or, how I learned to stop worrying and love foreign keys.

  • Nicholas Shirley
4 min read
Rails

Error Better: Effectively Utilize Active Model Errors with Rails in API Mode

Go beyond delivering just full_messages in Rails to send well formatted error messages using Rails API

  • Nicholas Shirley
3 min read
Rails

Using Font Awesome 5 in the Rails Asset Pipeline with Turbolinks

Want to use Font Awesome 5 with the Rails Asset Pipeline and Turbolinks? Read on to find out what you need.

  • Nicholas Shirley
2 min read
Rails

User authorization without cancan(can)

Building custom user authorization that integrates into Devise's current_user helper.

  • Nicholas Shirley
5 min read
Nicholas Shirley © 2023
Latest Posts Twitter Ghost