Skip to content

Instantly share code, notes, and snippets.

@deepak
Forked from jcasimir/gist:3247167
Created August 3, 2012 12:58
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 deepak/3247489 to your computer and use it in GitHub Desktop.
Save deepak/3247489 to your computer and use it in GitHub Desktop.
LOOKUP_CHAIN = [:params, :user, :session, :http, :default]
# hairy and cryptic
def self.set_by
lookup = LOOKUP_CHAIN.each
begin
meth = lookup.next
end while !(locale = send("by_#{meth}", meth) rescue nil);
locale
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment