ruby-on-rails - 如何使用注释 gem 注释 Rails 引擎模型?
问题描述
我正在尝试在 rails 6 项目中注释我的引擎。
在我拥有的 gem 文件中的根应用程序上
group :development do
gem 'annotate'
end
这就像预期的那样工作。当我每次运行迁移时,我的所有模型都完美注释
现在我的引擎 Gemfile 路径是components/engine_mame/Gemfile
我有
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
但是当我查看引擎中的模型时,我没有任何注释。我不确定我做错了什么
谢谢
解决方案
方法 1:使用生成的 rake 任务 ( rails g annotate:install
) 设置模型的路径,在model_dir
那里查找并使用逗号分隔符设置路径,例如
Annotate.set_defaults(
'model_dir' => 'app/models, engine_mame/app/models',
)
方法2:在每次调用时手动设置路径(逗号分隔,没有空格)
bundle exec annotate --model-dir app/models,engine_mame/app/models
推荐阅读
- python - 如何将一个常规格式的字符串列拆分为 Pandas 中的多个列
- python - 使用python在excel中创建和保存数据新表
- video - 使用 VLC 将视频流从相机写入文件
- php - processDatamap_beforeStart Hook - 获取 TYPO3 中的实际 UID
- python - 包含 for 循环的 Python 函数仅返回最后一个结果
- html - 页面链接在域的角度构建中不起作用
- html - HTML/CSS 表格单元在底部仅对齐一个按钮;
- html - css - 如何保持元素与较小显示器的关系
- php - Laravel 干预无法从给定的 WEBP 类型文件的二进制数据初始化
- python - 如何从python字典中提取相应的值?