脚手架不更新视图

发布于 2024-09-05 02:28:53 字数 237 浏览 3 评论 0原文

我对以下过程有疑问:

  • 脚本/生成脚手架产品 title:string description:text
  • db:migrate
  • 然后我生成一个迁移,将列描述添加到

    表产品并迁移数据库 再次。

我的问题是:为什么字段描述没有添加到项目视图中?这是正常的铁轨脚手架行为吗? 我想我在视频教程中看到脚手架也会更新视图,这会非常方便。 预先感谢您的任何帮助!

I have a question to the following procedure:

  • script/generate scaffold product
    title:string description:text
  • db:migrate
  • then I generate a migration which adds a column description to the

    table products and migrate the db
    again.

My question is: why is the field description not added to the project-views? Is that normal rails scaffold behaviour?
I think I saw in a video tutorial that the scaffold updates as well the views, which would be very convenient.
Thanks in advance for any help!

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

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

发布评论

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

评论(2

尐籹人 2024-09-12 02:28:53

这是正常的,因为脚手架不会“监视”表或任何其他脚手架相关资源(控制器、模型、视图、测试等)的更改。

然后我生成一个迁移
向表中添加列描述
产品展示

在生成脚手架时,您已经有了描述列。为什么您需要为此进行另一次迁移?

This is normal since scaffold does not "monitor" changes to the table or to any other scaffold-related resource (controller, model, views, tests, etc.).

then I generate a migration which
adds a column description to the table
products

You have description column already when generating the scaffold. Why do you need another migration for this?

面如桃花 2024-09-12 02:28:53

这是脚手架的正常行为,但是还有其他选择。

如果您要查看 Ryan Bates nifty_scaffold 生成器,那么这将允许您重新运行支架一代。 假设您没有更改生成的代码

这些生成器可以根据数据库模型的当前状态重新生成视图/规范/测试。

请注意,如果您已经自己自定义了视图,那么它们可能会被覆盖。

This is normal behaviour for scaffolding, however there are alternatives.

If you were to look at Ryan Bates nifty_scaffold generator then this would allow you to re-run the scaffold generation. Assuming that you hadn't changed the generated code.

These generators can regenerate the views/spec/tests based upon the current state of the database model.

Be aware that if you have already customised the views yourself then they could be overwritten.

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