Using annotate with Jets


#1

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

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

This causes annotate to fail here:


#2

Generally, annotate won’t work with Jets. Dug into it a little and a small change will allow annotating models to work: https://github.com/ctran/annotate_models/pull/626

It’s more work but you can use the forked version https://github.com/tongueroo/annotate_models

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
end
$ 

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


#5

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

gem ‘annotate’, git: ‘https://github.com/tongueroo/annotate_models.git’, :branch => ‘develop’