[英]How to annotate rails engine models with the annotate gem?
I am trying to annotate my engines inside of a rails 6 project.我正在尝试在 rails 6 项目中注释我的引擎。
on the root app in the gem file I have在我拥有的 gem 文件中的根应用程序上
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
现在我的引擎 Gemfile 路径是
components/engine_mame/Gemfile
and I have我有
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# 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谢谢
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, eg方法 1:使用生成的 rake 任务(
rails g annotate:install
)设置模型的路径,在那里查找model_dir
并使用逗号分隔符设置路径,例如
Annotate.set_defaults(
'model_dir' => 'app/models, engine_mame/app/models',
)
method 2: set paths manually on each call (comma-seeparated, without space)方法2:在每次调用时手动设置路径(逗号分隔,没有空格)
bundle exec annotate --model-dir app/models,engine_mame/app/models
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.