Last active
June 24, 2016 04:51
-
-
Save leandro/3a0a36d8495ca084e06995f98f3d7eb8 to your computer and use it in GitHub Desktop.
One user per week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Data < ActiveRecord::Base | |
belongs_to :user | |
before_create :user_allowed_to_create? | |
private | |
def user_allowed_to_create? | |
offset = Date.today.cweek % User.count | |
User.offset(offset).limit(1).pluck(:id).first == user_id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment