caffo (owner)

Revisions

  • 92fb27 Fri Mar 20 14:55:19 -0700 2009
gist: 82603 Download_button fork
public
Public Clone URL: git://gist.github.com/82603.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module ActionControllerExtensions
  def self.included(base)
    base::Dispatcher.send :include, DispatcherExtensions
  end
 
  module DispatcherExtensions
    def self.included(base)
      base.send :before_dispatch, :set_session_domain
    end
 
    def set_session_domain
      domain = @env['HTTP_HOST'].gsub(/:\d+$/, '').gsub(/^[^.]*/, '')
      puts "DOMAIN: #{domain}"
      @env['rack.session.options'].update :domain => domain
    end
  end
end
 
ActionController.send :include, ActionControllerExtensions