Skip to content

Instantly share code, notes, and snippets.

@etdebruin
Created April 15, 2015 03:21
Show Gist options
  • Save etdebruin/702d16c74e254c879fc8 to your computer and use it in GitHub Desktop.
Save etdebruin/702d16c74e254c879fc8 to your computer and use it in GitHub Desktop.
Set site_id via application_controller
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_site
# before_filter :set_site
# def set_site
# $site = Site.find_by_url(request.host)
# session[:site_id] = Site.find_by_url(request.host).id
# if current_site.nil?
# $site = Site.new
# current_site.title = "Dev'ing"
# end
# end
def current_site
@_current_site ||= Site.find_by_url(request.host)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment