How to Annotate Rails Engine Models with the Annotate Gem?

I am trying to annotate my engines inside of a rails 6 project.

on the root app in the gem file I have

group :development do
  gem 'annotate'
end

and this works just as expected. When every I run migrations all my models annotate perfectly

now my engine Gemfile path is components/engine_mame/Gemfile

and I have

source '
git_source(:github) { |repo| "" }

# Specify your gem's dependencies in engine_mame.gemspec.
gemspec

group :development do
  gem 'annotate'
  gem 'pg'
end

but when I look at the models in my engine I do not have any annotations. I am not sure what I am doing wrong

Thanks

1 Answer

method 1: set paths to models using generated rake task (rails g annotate:install), look for model_dir there and set paths using comma separator, e.g.

Annotate.set_defaults(
  'model_dir' => 'app/models, engine_mame/app/models',
)

method 2: set paths manually on each call (comma-seeparated, without space)

bundle exec annotate --model-dir app/models,engine_mame/app/models

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest