Skip to content

Instantly share code, notes, and snippets.

@skarger
Last active June 14, 2019 17:11
Show Gist options
  • Save skarger/4739267300c2164375672897d0af7221 to your computer and use it in GitHub Desktop.
Save skarger/4739267300c2164375672897d0af7221 to your computer and use it in GitHub Desktop.
class Sport < ApplicationRecord
has_many :workouts
has_one :most_recent_workout, -> do
merge(Workout.most_recent_by_sport)
end, class_name: "Workout", inverse_of: :sport
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment