Rails 应用程序控制器的批评(随意严厉)

发布于 2024-07-15 05:15:27 字数 374 浏览 2 评论 0原文

我编写了一个应用程序控制器,它可以处理我需要任何控制器完成的 99% 的任务。 我已将其发布在此处 (pastebin)。 就像我说的,随意严厉。

-更新:添加评论:)

谢谢,

-C

P.S. 我想说,我的目的是覆盖子类控制器中需要不同功能的方法,例如 _message 方法和 after_ 方法。 应用程序控制器将充当一种抽象类。 另外,一些 before_filters 是特定于插件的,例如tiny_mce和restful_authentication(恕我直言,这太棒了。)

I've written an application controller that handles 99% of what I need any controller to do. I've posted it here (pastebin). Like I said, feel free to be harsh.

-update: added comments :)

Thx,

-C

P.S. I would like to say that my intention here is to overwrite methods that need different functionality in sub-classed controllers, such as the _message methods and the after_ methods. The application controller will serve as a sort of abstract class. also, some of the before_filters are specific to plugins, such as tiny_mce and restful_authentication (which is awesome, imho.)

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

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

发布评论

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

评论(2

与君绝 2024-07-22 05:15:27

这不是您问题的答案,但如果您想朝这个方向更进一步,您可能需要看看 Hobo 。 它的 Hobo::ModelController 做了很多事情您的 ApplicationController 的作用。

This is not an answer to your question, but if you want to go further in this direction, you may want to take a look at Hobo. Its Hobo::ModelController does a lot of what your ApplicationController does.

-残月青衣踏尘吟 2024-07-22 05:15:27

小事,但我会将对象、模型和 model_name 方法设为私有或受保护。 除此之外我没有发现任何错误。

Small thing, but I would make the object, model, and model_name methods private or protected. Other than that I didn't notice any mistakes.

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