Skip to content

Instantly share code, notes, and snippets.

@xdite
Created July 8, 2013 12:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdite/5948350 to your computer and use it in GitHub Desktop.
Save xdite/5948350 to your computer and use it in GitHub Desktop.
def find_blog
case request.host
when "www.#{Setting.host}", Setting.host, nil
@current_blog = Blog.find_by_subdomain(request.subdomain)
else
if request.host.index(Setting.host)
@current_blog = Blog.find_by_subdomain(request.host.split('.').first)
else
@current_blog = Blog.find_by_fqdn(request.host)
end
if !@current_blog
redirect_to Setting.domain
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment