我应该如何在 Rails 中创建半天活动

发布于 2024-10-16 21:56:08 字数 404 浏览 4 评论 0原文

我正在 Rails 中创建一个应用程序,它本质上是一个假期管理工具。员工要求休假;发送电子邮件给经理以供批准;经理批准/拒绝等。

该应用程序将允许休全天或半天假期,我想知道处理半天假期的最佳方式。我不想向用户展示时间选择器。我更愿意提供日期选择器和上午/下午复选框。

我想我正在寻找关于是否应该 1) 结合使用所选日期和 AM 复选框来在数据库中创建日期时间条目的意见,例如休假于 2 月 10 日在 AM =“2011-02-10 00”中开始:00" 或 2) 我应该简单地在数据库中记录一个日期,并在一个单独的字段中使用对 AM 的字符串引用。

我想以 .ics 文件和流的形式输出 left,因此第一个选项对我来说最有意义,但可能会在代码中创建一个真正的谎言。任何想法或进一步的选择表示赞赏。

谢谢罗宾

I'm creating an app in Rails that is essentially a holiday management tool. Employee requests holiday; email sent to manager for approval; manager approves/rejects etc.

The app will allow whole or half-day holidays to be taken and I'm wondering about the best way to handle the half-days. I don't want to present the user with a time picker. I would prefer to offer a date-picker and AM/PM checkboxes.

I suppose I'm looking for opinion on whether I should 1) use the chosen date in conjunction with say the AM checkbox to create a DateTime entry in the DB e.g. leave starts on 10 February in the AM = "2011-02-10 00:00" or 2) should I simply record a Date in the DB with a string reference to AM in a separate field.

I want to output leave in the form of .ics files and a stream so the first option to me makes the most sense but is likely to create a real fudge in the code. Any thoughts or further options appreciated.

Thanks

Robin

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

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

发布评论

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

评论(1

苏辞 2024-10-23 21:56:08

为什么不为每个假期而不是仅为一个假期创建持续时间(一对日期时间)?这应该比仅仅将单个时间存储为事件更好地对物理表示进行建模。


至于如何在视图级别处理这个问题,您可能会想要使用演示者模式,因为您实际上是在操纵事件而不是时间。

演示者基本上是一个添加了业务逻辑的代理,它代表了视图与模型交互方式的更好映射。

它是一个轻量级层(它们通常只是普通的 Ruby 类,而不是 AR::Base 或其他重量级 Rails 模型),用于包装您的模型,并且通常在控制器级别实例化,并传递给您的视图而不是模型本身。

http://blog.jayfields.com/2006/09 /rails-model-view-controller-presenter.html
http://blog.jayfields.com/2007/03/rails-presenter -pattern.html
http://www.slideshare.net/adorepump/presenting-presenters-on-rails


这就是我的意思:https://gist.github.com/984025

Why not create durations (pairs of datetimes) for every holiday rather than just one? That should model the ical representation better than just storing single times as events.


As far as how to handle that at the view level, you're probably going to want to use the Presenter Pattern since you're really manipulating events rather than times.

A presenter is basically a proxy with added business logic that represents a better mapping for how the view interacts with the model.

It's a lightweight layer (they're normally just normal Ruby classes, rather than AR::Base or other heavyweight rails models) that wrap your models, and are usually instantiated at the controller level, and passed to your views rather than the model themselves.

http://blog.jayfields.com/2006/09/rails-model-view-controller-presenter.html
http://blog.jayfields.com/2007/03/rails-presenter-pattern.html
http://www.slideshare.net/adorepump/presenting-presenters-on-rails


Here's what I mean: https://gist.github.com/984025

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