如何为已经到位的模型创建脚手架
我已经有了一个模型。我只想为其创建一些管理屏幕,以执行添加/编辑/更新/删除功能。
我的模型名称是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信你可以使用 nifty_scaffold 为此
I believe you can use nifty_scaffold for this
听起来您只需要一个管理控制器+用户视图。您应该强烈考虑管理区域的名称空间(这可以通过 Rails 3 中的以下生成器轻松实现):
此外,如果您还希望基于现有的用户模型生成视图:
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):
additionally, if you also want the views generated, based on an existing User model: