如何为已经到位的模型创建脚手架

发布于 2024-08-19 22:11:10 字数 338 浏览 3 评论 0原文

我已经有了一个模型。我只想为其创建一些管理屏幕,以执行添加/编辑/更新/删除功能。

我的模型名称是 User,它具有属性 user_id、first_name、last_name、user_status、created_at、updated_at、updated_by

是否可以在此模型上使用 script/generatescaffold 以便增删改查功能将自行出现,然后我可以让它看起来像应用程序的其余部分。

我不知道这是否有什么不同,但 user 模型与另一个表有 has_many through 关系

I have a model already in place. I just want some admin screens created for it which will do the add/edit/update/delete functionality.

My model name is User and it has properties user_id, first_name, last_name, user_status, created_at, updated_at, updated_by

Is it possible to use the script/generate scaffold on this model so that crud functionality would come on its own and then I can just make it look like rest of the application.

I dont know if it makes a difference but the user model has a has_many through relationship with another table

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

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

发布评论

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

评论(2

凉世弥音 2024-08-26 22:11:10

我相信你可以使用 nifty_scaffold 为此

I believe you can use nifty_scaffold for this

溺孤伤于心 2024-08-26 22:11:10

听起来您只需要一个管理控制器+用户视图。您应该强烈考虑管理区域的名称空间(这可以通过 Rails 3 中的以下生成器轻松实现):

rails generate controller Admin::Users

此外,如果您还希望基于现有的用户模型生成视图:

rails generate scaffold_controller Admin::Users

Sounds like you simply need an admin controller + views for Users. You should strongly consider name-spacing the admin area (which is easily possible via the following generator in rails 3):

rails generate controller Admin::Users

additionally, if you also want the views generated, based on an existing User model:

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