evanwalsh (owner)

Revisions

gist: 33747 Download_button fork
public
Public Clone URL: git://gist.github.com/33747.git
setting.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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