Reputation: 155
I'm trying to build a trial period checker and I'm trying to test whether a user was created inside the 14 day period. So if its outside 14 days then I get a false. Thoughts?
if @user.trial_period === true
trial_users = User.where(created_at:14.days.ago..Time.current.end_of_day)
@trial_check_user = trial_users.where('id = ?', current_user.id)
if @trial_check_user.first.present?
@user_in_trial = true
puts "!!!!!!! USER STILL IN TRIAL WINDOW !!!!!!!".red
else
@user_in_trial = false
puts "!!!!!!! NOT IN TRIAL NEED SUBCRIPTION !!!!!!!".red
redirect_to new_subscription_path
end
Upvotes: 0
Views: 40
Reputation: 3521
if current_user.created_at > 14.days.ago
# Still in trial
@trial_check_users = User.where('created_at > ?', 14.days.ago).count
else
@trial_check = false
redirect_to new_subscription_path
end
Upvotes: 1