I have a User model, a user has_many leave_requests, in the user model I have the following code to find the last 5 leave requests:  def last_five_leave_requests    leave_requests.order(:updated_at).limit(5).reverse  endI kind of feel this code should live in the LeaveRequest model, what is the Rails way here to structure this?
Getting last 5 leave requests for a user - where does the code live
ruby;ruby on rails;active record
Add in leave_request.rb:scope :last_five, -> { order(updated_at: :desc).limit(5) }And you can use:LeaveRequest.last_fivemodel_that_has_many_leave_requests.last_five