Rails 2.2.2 中的动态脚手架
class AdminController < ApplicationController
scaffold :product
end
上面的代码在 Rails 1.2 中可以正常工作。 但对于上面提到的代码,它给出了 Rails 2.2.2 中缺少“scaffold”的错误方法。 上面的代码用于Rails 1.2中的动态脚手架。 Rails 2.2.2 支持这个动态脚手架吗?
或者我是否需要在 Rails 2.2.2 中使用 ruby script/generate 'model_name' field_names 来生成静态脚手架?
class AdminController < ApplicationController
scaffold :product
end
Above code works properly in Rails 1.2. But for the above mentioned code it gives error method missing 'scaffold' in Rails 2.2.2. Above code is used for dynamic scaffolding in Rails 1.2. Is this dynamic scaffolding supported in Rails 2.2.2?
or do I need to use ruby script/generate 'model_name' field_names to generate static scaffolding only, in Rails 2.2.2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
动态脚手架已被弃用。 正如您所提到的,您应该使用以下方式生成它们:
您可以在没有任何参数的情况下运行它来获取内置帮助和语法。
我记得阅读过(甚至可能在这个网站上)的原因是脚手架只是开始构建应用程序的一种方法,它生成的代码不应该用于生产网站。 通过让脚手架生成代码供您编辑并满足您的需求,比每次生成代码要灵活得多。
Dynamic scaffolding has been deprecated. As you mentioned, you should just generate them using:
you can run that without any arguments to get the built-in help and syntax.
The reason I remember reading (it may have even been on this site) is that the scaffold is just a way to get started on building your application, the code that it generates should not be used for a production site. By having the scaffold generate the code for you to edit and suit your needs is much more flexible than having the code generated each time.