Skip to content

Instantly share code, notes, and snippets.

@dogweather
Created October 2, 2022 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogweather/fe67c047e643de4ed34eb40e7b5fcdb0 to your computer and use it in GitHub Desktop.
Save dogweather/fe67c047e643de4ed34eb40e7b5fcdb0 to your computer and use it in GitHub Desktop.
Example of memoization in Ruby on Rails
class Jurisdiction < ApplicationRecord
# ...
class << self
memoize def find_via(slug:)
Jurisdiction.find_by(slug: slug)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment