Rails 2.2.2 中的动态脚手架

发布于 2024-07-15 08:50:50 字数 327 浏览 6 评论 0原文

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 技术交流群。

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

发布评论

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

评论(1

永不分离 2024-07-22 08:50:50

动态脚手架已被弃用。 正如您所提到的,您应该使用以下方式生成它们:

./script/generate scaffold

您可以在没有任何参数的情况下运行它来获取内置帮助和语法。

我记得阅读过(甚至可能在这个网站上)的原因是脚手架只是开始构建应用程序的一种方法,它生成的代码不应该用于生产网站。 通过让脚手架生成代码供您编辑并满足您的需求,比每次生成代码要灵活得多。

Dynamic scaffolding has been deprecated. As you mentioned, you should just generate them using:

./script/generate scaffold

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.

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