Skip to content

Instantly share code, notes, and snippets.

@jarod022
Created March 22, 2017 17:13
Show Gist options
  • Save jarod022/0e94fc83eb9077649fb34a168d76b6ec to your computer and use it in GitHub Desktop.
Save jarod022/0e94fc83eb9077649fb34a168d76b6ec to your computer and use it in GitHub Desktop.
Rails: how to save up database queries using cache
class ApplicationController < ActionController::Base
before_action :fetch_settings
helper_method :settings
private
def fetch_settings
@__settings = SettingsCacher.new.fetch
end
protected
def settings
@__settings
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment