带有 ajax 选项卡和验证的 Rails Web 应用程序控制面板

发布于 2024-07-17 00:14:19 字数 411 浏览 6 评论 0原文

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

这是我无法理解的。 通常,我会为每个选项卡都有一个控制器,因此验证很简单,如果出现错误(例如用户中的错误),我只需使用对象呈现正确的操作,它是错误的,我们就设置好了。 但是,如果我不刷新(选项卡之间的不同控制器),这是如何工作的? 我是否需要拥有一个包含所有用户、项目、任务验证和控制(即增删改查操作)的大型控制器? 似乎不是最伟大的设计。

或者有什么方法可以使用包含单独控制器的“管理”控制器来进行正确的增删改查/错误检查等。

希望这有意义吗?

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.

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

Hope this makes sense?

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

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

发布评论

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

评论(2

野侃 2024-07-24 00:14:19

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

  • 现在每个选项卡都可以轻松成为不同的视图/控制器
  • 您只需在使用选项卡时加载选项卡的内容; 您不会为用户不使用的选项卡处理代码/下载 html。

如果您不想使用此路线(即您觉得需要在单个请求中加载页面下载上选项卡的所有内容),那么您可以使用辅助方法和部分代码分离出代码。 请在此处查看我的答案:Rails 子控制器?

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

  • Now each tab can easily be a different view/controller
  • You only need to load the contents for a tab when it is used; you won't be processing code/downloading html for tabs that the user doesn't use.

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?

清风疏影 2024-07-24 00:14:19

我个人会在表单中使用内联验证。 Jquery 做得很好 well ,但是有很多库可以帮助您。

我想这并不完全是您想要的,但它会让您的工作更轻松。 当然,仍然在模型中保留验证,这样就没有人可以绕过验证(使用 firebug 或类似的东西)

I would personally use inline validation in the forms. Jquery does that pretty well , but there are a lot of library that can help you with that.

I guess it's not exactly what you were looking for, but it would make your job easier. Of course still keep validation in the models so that no one can bypass the validation (using firebug or something like this)

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