For instance, if a user submits a post, there should be a delay period of maybe 10 minutes in which he or she cannot submit another post.
Could someone point me to a good gem/tutorial/method? For reference, I’m on Rails 3.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your tracking by user, you can keep a column called
last_activewhich is a datetime field, and update it when the user submits the form. (Assuming there aren’t a lot of form,s, then maybe think about giving these timestamps their own model).Then, just perform date math to see if ten minutes has gone by.
user.last_active + 10.minutes > Time.now ? "User can post" : "User cannot post"Note: Not in front of a console, that might be
10.minuteThen your form logic: