Created
December 9, 2008 03:32
-
-
Save evanwalsh/33747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A model for Ruby on Rails that gets settings from a DB | |
# And it caches them! Success! | |
class Preference < ActiveRecord::Base | |
def self.get(name) | |
return Rails.cache.fetch(name) { | |
output = self.find_by_name!(name) | |
Rails.cache.write(name,output.value) | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment