class User < ActiveRecord::Base
  belongs_to :group
  has_many :made_requests, class_name: 'Request', foreign_key: 'requester_id'
  has_many :fulfilled_requests, class_name: 'Request', foreign_key: 'responder_id'
  has_many :votes, as: :voter
  has_many :votes, as: :candidate

  validates :first_name, :last_name, presence: true
  validates :email, presence: true, uniqueness: true
end

class User < ActiveRecord::Base
  belongs_to :group
  has_many :made_requests, class_name: 'Request', foreign_key: 'requester_id'
  has_many :fulfilled_requests, class_name: 'Request', foreign_key: 'responder_id'
  has_many :votes, as: :voter
  has_many :votes, as: :candidate

  validates :first_name, :last_name, presence: true
  validates :email, presence: true, uniqueness: true

  def requests_in_last_24_hours
    conditions = { requester_id: id, created_at: (Time.now - 1.day..Time.now) }
    Request.where(conditions).count
  end
end

Add a method requests_in_last_24_hours to the User model.
Add a method requests_in_last_24_hours to the User model.

This returns the number of requests the user has made in the last 24
hours.
