带有ajax选项卡和验证的Rails Web应用程序控制面板 [英] Rails web application control panel with ajax tabs and validation

查看:131
本文介绍了带有ajax选项卡和验证的Rails Web应用程序控制面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个带有管理控制面板的Rails Web应用程序.我希望控制面板使用选项卡式界面来控制用户,项目,任务等,并且我想使用带有ajax的jquery选项卡UI控件在选项卡之间切换.还对用户使用静态身份验证,并对项目,任务等使用我自己的代码.

I'm looking to build a rails web app with an admin control panel. I'd like the control panel to use a tabbed interface for controlling users, projects, tasks etc, and I'd like to switch between tabs using jquery tab UI controls with ajax. Also using restful authentication for users and my own code for projects, tasks etc.

这是我无法解决的问题.通常,每个选项卡都有一个控制器,因此验证很简单,如果出现错误(在用户中说),我只是对该对象执行正确的操作,这是错误的,我们就开始了.但是,如果我不刷新(到选项卡之间的不同控制器),这将如何工作?我是否需要一个包含所有用户,项目,任务验证和控件(例如,粗体操作)的大型控制器?似乎不是最好的设计.

Here's what I can't wrap my head around. Normally, I'd have a controller for each tab, so validation is simple, if there's an error (say in the user) i just render the proper action with the object and it's errors and we're set. However, if I'm not refreshing (to different controllers between tabs) how does this work? Do I need to have one massive controller with all the user, project, task validation and controls (ie. crud operations)? Seems like not the greatest design.

或者我可以通过某种方式使用"admin"控制器,该控制器包含单独的控制器,以进行适当的粗略/错误检查等.

Or is there some way I can use an 'admin' controller that encompasses separate controllers for proper crud/error checking etc.

希望这有意义吗?

推荐答案

我将使每个选项卡的内容由单独的ajax请求调用.这将为您带来以下好处

I would make the contents of each tab be called in by a separate ajax request. This would give you the following benefits

  • 现在每个选项卡可以轻松地成为不同的视图/控制器
  • 使用选项卡时,您只需要为其加载内容;您将不会为用户不使用的标签页处理代码/下载html.

如果您不想使用此路由(即您认为需要在单个请求中加载页面下载中所有标签的内容),则可以使用辅助方法和局部代码来分离代码.在这里查看我的答案:是铁路副控制器吗?

If you don't want to use this route, (i.e. you feel you need to load all the contents of the tabs on page download in a single request) then you could separate out the code using helper methods and partials. See my answer here: Rails Sub-controllers?

这篇关于带有ajax选项卡和验证的Rails Web应用程序控制面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆