Ruby/Rails:生成脚手架的代码在哪里
我正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://github.com /rails/rails/blob/master/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
你找到了吗?如果您找到它的要求 resource_generator,您将找到创建路由的代码。如果您追踪resource_generator的需求,您将找到模型生成器、辅助生成器等。
您不会找到任何生成所有内容的单个文件。
如果我完全误解了你的问题,而你只是想知道命令是什么,那就是:
Rails version < 3.0.0
Rails 版本>> 3.0.0
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:
Rails version < 3.0.0
Rails version > 3.0.0