class Vote < ApplicationRecord
  belongs_to :meme, dependent: :destroy
  belongs_to :user, dependent: :destroy

  validates_uniqueness_of :meme_id, scope: :user_id

  def voted(user:)
    return false unless user
    
    votes.where(user_id: user.id).any?
  end
end
