title: Date range overlap per user rails
body: <p>How can I make the validation of the date per user using the code below? When I logged in as a different user I am not able to create a reservation with the same dates. I have user_id which references id in the table users. I want to be able to make the date_start and date_end unique to only the user and still be able to create the same dates with a different user. </p>
  
  <p>Link for more information:
  <a href="https://stackoverflow.com/questions/47276147/validation-between-two-date-rails">Validation between two date rails</a></p>
  
  <pre><code>validate :no_reservation_overlap
  
   scope :overlapping, -&gt;(period_start, period_end) do
      where "((date_start &lt;= ?) and (date_end &gt;= ?))", period_end, period_start
   end
  
  
  private
  
  def no_reservation_overlap
    if (Reservation.overlapping(date_start, date_end).any?)
       errors.add(:date_end, 'it overlaps another reservation')
    end
  end
  </code></pre>