改变生成的脚手架模型的当前结果

发布于 2025-01-16 19:32:18 字数 1409 浏览 2 评论 0原文

我的目标是对当前的脚手架生成器进行一些涡轮添加。为此,我需要模型中的plural_model_name。我正在寻找一种方法来更改由rails gscaffold命令生成的输出模型。

class <%= singular_model_name %> < ApplicationRecord
  broadcasts to: <%= plural_model_name %>
end

任何人都可以给我一个正确的方向推动吗?如果可以给出一些关于我应该将猴子补丁版本放在 /lib/ 中的哪个文件夹中的说明,我也会非常感激。

我已经浏览了几乎所有的生成器这里 但我似乎无法掌握模型的处理位置。

与模型相反,我已经成功地能够更改 查看模板, 视图生成器,以及<一href="https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt" rel="nofollow noreferrer">控制器模板和<一个href="https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb" rel="nofollow noreferrer">ScaffoldControllerGenerator 用于脚手架发电机。

I aim to make some turbo additions to the current scaffold generator. For that i need the plural_model_name in the model. I am looking for a way to alter the output model, generated by the rails g scaffold command.

class <%= singular_model_name %> < ApplicationRecord
  broadcasts to: <%= plural_model_name %>
end

Can anyone give me a nudge in the right direction?, I would also be very thankful if some instructions can be given as to in which folder in /lib/i am supposed to place the monkey-patched version.

I have been going through nearly all generators here but i cannot seem to get a grasp of where the model is taken care of.

Contrary to the model i have successfully been able to alter the view templates, view generator, and controller template and ScaffoldControllerGenerator for the scaffold generator.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文