简体   繁体   English

如果用户在2天内发布,如何防止发布?

[英]How prevent posting if user posted in less than 2 days?

I want to prevent data from being submitted if current_user has posted in less than 2 days ? 如果current_user在不到2天的时间内发布,我想阻止提交数据吗?

<%= form_for @post do |x|%>
<% x.text_area :content %>
<%= x.submit %>

您可以简单地检查当前用户的最新帖子是否> = 2天前...

if current_user.posts.last.created_at >= 2.days.ago

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM