The Captain's Log

Tales of achievement, bewilderment, and a surly relationship with a computer.
Tagged with: rails
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. ...
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 ...
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 ...
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 time...
System Tests with RSpec, Rails, Capybara, and Devise
Since the release of RSpec 3.7 we've been able to take advantage of system tests which are new as of Rails 5.1. If you've been using RSpec for a while you're already likely familiar with feature tests using Capybara. For those new to these types o...
ActionMailer SMTP settings for SendGrid (Rails)
Okay, I got no Google hits for this. Here's a tip if you're using SendGrid in a Rails app for your transactional emails. A while back you needed to provide your SendGrid username and password (hopefully via environment variables), but now you can ...
Heroku defaults to Puma for Rails 5
It's now going to be easier than ever to kick off a new Rails project and deploy to Heroku. WEBrick is no longer the default server with Rails 5. If you don't provide a Procfile Heroku is going to help you out and set you up with Puma. Production ...
How to Create a Contact Form Using Rails and Mandrill
Let's build a simple contact form for your Rails driven website that uses Mandrill as the desired email server. Mandrill lets us offload the management of setting up and running an email server ourselves and, therefore, relieving ourselves of a ma...
Syntax Highlighting in Rails
Your Rails driven website has the need to display some code. It's not good enough to just get proper indentation, you'd like to have some decent syntax highlighting. Maybe something like following. There's a great ruby gem called Rouge that makes...
Editing a form using fields_for in Rails
Let's say you'd like to successfully create or update a nested form using fields_for. Our 'parent' will be a Post model and our 'child' will be a Tag model. It's not hard, but there's a bit of a gotcha that I found most other resources out there w...