Gems

Development snippets.


RSpec not_change

You can add your own support for the absent not_change matcher.

John NorrisSeptember 11 2024

A Collection Containing Exactly

A great way of testing a collection in RSpec without needing to care about the order.

John NorrisSeptember 4 2024

Locating Active::Storage attachments

It can be a bit of a mystery, but they've used a simple pattern.

John NorrisAugust 29 2024

Who really wrote that code?

A better way of using git blame to give you a more accurate result.

Adam DawkinsMay 8 2024

ActiveRecord composed_of

Allows us to use Value Objects for things that are part of our models.

Adam DawkinsFebruary 21 2024

update_all is very different to update

update goes via the ActiveRecord record, while update_all writes to the column in SQL.

Adam DawkinsFebruary 3 2024

link_to_if could be a trap

link_to_if is a great way to conditionally render a link, but it can be a trap if you're not careful.

John NorrisFebruary 2 2024

Clamping in JavaScript

I've got a number, and I want that number, or 0 or 100 if it overflows in either direction

John NorrisDecember 15 2023

Blank Options in Required Select Boxes

You apparently can’t combine include_blank and required on a select box, which seems odd.

John NorrisNovember 10 2023

Turbo Frames within View Components

There seems to be a solveable issue with using turbo_frame_tag within view components.

Rich ButlerNovember 8 2023

Running Rails Tests in Parallel

Using the parallel_tests gem and running the tests in parallel, the whole suite ran in 39 seconds, rather than the usual 4-5 minutes.

Will HodgsonOctober 23 2023

Comparing Date and TimeWithZone

Rails does weird rounding in comparisons between Date and ActiveSupport::TimeWithZone classes.

Adam DawkinsSeptember 15 2023

Clear out temp storage after RSpec completion

The tmp/storage folder can grow quickly, and before you know it it's taken over.

Will HodgsonSeptember 7 2023

Devise Trackable Timestamps

Devise trackable stores useful timestamps for when users did things, but they aren't very clear.

John NorrisJuly 19 2023

Schema.rb version and Heroku

The timestamp that’s passed to version in db/schema.rb is very important to get right, especially in merges.

John NorrisJuly 3 2023

SSL issues when installing Ruby with RVM

This might be your solution if you’re struggling with SSL issues while installing a version of Ruby with RVM

John NorrisMay 22 2023

The one-sided Turboframe

Using a Turboframe with a src can be a trap.

John NorrisApril 5 2023