Skip to content

Instantly share code, notes, and snippets.

View GlenCrawford's full-sized avatar

Glen Crawford GlenCrawford

View GitHub Profile
@GlenCrawford
GlenCrawford / reinteractive blog post: An interview with an AI about Ruby on Rails.md
Last active December 10, 2022 03:24
reinteractive blog post: An interview with an AI about Ruby on Rails

Earlier this week OpenAI, an Artificial Intelligence research laboratory co-founded by Elon Musk, released ChatGPT, a new model that is able to converse in an extremely human-like way. It is available now for research purposes, and since our Growth and Expansion Manager Monique is practically begging for blog posts about Ruby on Rails, I thought I would see if ChatGPT can do 99% of the work for me. Let's give it a go, and as we do, bear in mind that the ChatGPT model isn't actually connected to the internet, meaning that it isn't looking up the relevant information on demand in order to answer: it already knows it.

Glen:

Hi, my name is Glen. Could you please help me write a blog post about Ruby on Rails, which is what my company, reinteractive, specializes in?

ChatGPT:

Sure, I'd be happy to help! Here are a few points you could include in your blog post about Ruby on Rails:

@GlenCrawford
GlenCrawford / Detecting unused routes with Rails 7.1.md
Created November 10, 2022 00:43
reinteractive Blog Post: Detecting unused routes with Rails 7.1

When looking at upcoming major releases of projects like Ruby on Rails, it can be easy to get distracted by the big, flashy features, such as Hotwire and encrypted attributes in Rails 7.0. However, sometimes I find myself getting more excited by smaller, more modest additions in upcoming releases. This is the case with the recent merge of a PR to Rails that will form part of Rails 7.1: Add routes --unused option to detect extraneous routes by Gannon McGibbon.

We all know the rails routes command which lists all the routes in your app, detailing their name, HTTP method, path, controller and action. But in a large app with lots of routes that might have seen a rewrite or two or a few years of churn, how do you know which routes are still valid (where "valid" means the controller and action that the route points to exists)?

Introducing the new --unused option (full command: rails routes --unused).

From an implementation point-o

@GlenCrawford
GlenCrawford / schema_dumper.rb
Created April 17, 2020 13:59
Patching Rails database schema dumps to support multiple PostgreSQL schemas.
# Overrides Rails file activerecord/lib/active_record/schema_dumper.rb to
# include all schema information in the db/schema.rb file, for example, in the
# create_table statements. This allows for a working development database
# to be built from a schema.rb file generated by rake db:schema:dump.
#
# This is essentially a rebuild of the "schema_plus_multischema" gem (which is
# unfortunately only compatible with Rails ~> 4.2).
#
# Tested with Rails 6.0.