Using annotate with Jets

Has anyone used annotate in a Jets project?
Under Jets:

irb(main):002:0> Rails::Application.subclasses
=> []

This causes annotate to fail here:

Generally, annotate won’t work with Jets. Dug into it a little and a small change will allow annotating models to work:

It’s more work but you can use the forked version

Here’s a test example with the forked version.

$ annotate
Model files unchanged.
$ cat app/models/post.rb                                                                                                               
# == Schema Information
# Table name: posts
#  id         :bigint           not null, primary key
#  title      :string(255)
#  body       :text(65535)
#  published  :boolean
#  created_at :datetime         not null
#  updated_at :datetime         not null

class Post < ApplicationRecord

Note, annotate will not work with routes though. The Jets routing layer is a completely different implementation than Rails.

Also, you need to be running Jets v1.9.8+ The autoloaders were changed in this version. For the annotate fork to work, you need at least v1.9.8

1 Like

Thank you!
I can annotate models now with this in my Gemfile:

gem ‘annotate’, git: ‘’, :branch => ‘develop’

PR needs a test. If you’re interested, feel free to add. No sweat either way of course.