Ruby/Rails:生成脚手架的代码在哪里

发布于 2024-11-27 05:01:15 字数 75 浏览 1 评论 0原文

我正在 github.com/rails/rails 上浏览代码,但我无法弄清楚生成 Rails 脚手架的代码在哪里。有人能解释一下吗?

I was browsing the code at github.com/rails/rails, and I couldn't figure out where the code was to generate Rails scaffolds. Can anybody shed some light on this?

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

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗫嚅 2024-12-04 05:01:15

https://github.com /rails/rails/blob/master/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb

你找到了吗?如果您找到它的要求 resource_generator,您将找到创建路由的代码。如果您追踪resource_generator的需求,您将找到模型生成器、辅助生成器等。

您不会找到任何生成所有内容的单个文件。

如果我完全误解了你的问题,而你只是想知道命令是什么,那就是:

cd your/application/directory

Rails version < 3.0.0

script/generate scaffold model_name column_name:column_type

Rails 版本>> 3.0.0

rails g scaffold model_name column_name:column_type

https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb

Did you find that? If you track down it's require, resource_generator, you'll find the code that creates the route. If you track down the resource_generator's requires, you'll find the model generator, helper generator, etc.

You won't find any single file that generates everything.

If I totally misunderstood your question and you just want to know what the command is, it's:

cd your/application/directory

Rails version < 3.0.0

script/generate scaffold model_name column_name:column_type

Rails version > 3.0.0

rails g scaffold model_name column_name:column_type
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文