防止用户在任何月份的特定日期编辑帖子

Prevent User Edits to Posts on Certain Days on Any Month

我在 ruby 的目标是在全年的每个月的某些日子里 posts 不允许 useredit

monthfirst 7 days 将是 excluded 以及任何给定月份的 last 3 days

我看到我可以通过文档对每个月的天数进行硬编码,但还没有找到比每个月一次 excludingarray of dates 更灵活的方法没有用特定月份进行硬编码。

active admin rails 5

中使用 jQuery UI date-picker

如果有示例或有人问过如何完成此操作,请指出。

感谢您的宝贵时间。

编辑:我可能已经通过 GroupDate Gem

找到了我的解决方案
(1..7).to_a + (Date.civil(Date.curent.year, Date.curent.month, -3)..Date.civil(Date.curent.year, Date.curent.month, -1)).to_a #disabled days
(8..Date.civil(Date.curent.year, Date.curent.month, -4)) #allowed days