Rails 3.1 可排序嵌套集,带有 jquery 和两个模型
这是我的问题,我希望有人能指出我正确的方向。我想利用拖放来创建动态的餐饮/餐厅菜单。我想创建一个可以添加部分的视图,然后将菜单项添加到该部分(以及可能的子部分)。我很容易理解如何使用一个模型来完成此任务,但我想将部分和菜单项保留在单独的模型中。我将如何设置可排序嵌套集合宝石以使用双模型?我应该重新考虑并使用一种模型吗?任何指导将不胜感激。
Here is my issue, I hope someone can point me in the right direction. I am wanting to utilize drag and drop to create a dynamic catering/restaurant menu. I would like to create a view that I can add Sections and then add MenuItems to that section (and possible subsections). I understand fairly easily how I can accomplish this with one model, but I would like to keep sections and menu items in separate models. How would I go about setting up the sortable nested set gem to use dual models? Should I rethink and use one model? Any guidance would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果使用一种模型会更容易。
菜单项的方法似乎不错。您可以编写 active_record 回调来在菜单项模型中添加和删除部分/餐饮/餐厅。
nested_set gem 的 GUI
https://github.com/the-teacher/the_sortable_tree
It is easier if you use one model.
The menu item approach seems to be nice. You can write active_record callbacks to add and remove sections/catering/restaurant to and from the menu items model.
GUI for a nested_set gem
https://github.com/the-teacher/the_sortable_tree