diff --git a/README b/README index c2bc87f..3db004b 100644 --- a/README +++ b/README @@ -1,13 +1,10 @@ -Submarine -========= +=== Submarine -Introduction goes here. +Handy controller and helper methods to grab the current subdomain. +=== Instructions -Example -======= - -Example goes here. +TODO === Copyright (c) 2008 Norbauer Inc, released under the MIT license -=== Written by Jose Fernandez and Ryan Norbauer, with support from The Sequoyah Group +=== Written by Jose Fernandez with support from The Sequoyah Group diff --git a/init.rb b/init.rb index 3c19a74..e69de29 100644 --- a/init.rb +++ b/init.rb @@ -1 +0,0 @@ -# Include hook code here diff --git a/lib/submarine.rb b/lib/submarine.rb index 0d69466..7789b3e 100644 --- a/lib/submarine.rb +++ b/lib/submarine.rb @@ -1 +1,23 @@ -# Submarine +module Submarine + + mattr_writer :subdomain_model + def self.subdomain_model + @@subdomain_model ||= 'user' + end + + mattr_writer :subdomain_column + def self.subdomain_column + @@subdomain_column ||= 'login' + end + + def self.included(controller) + controller.helper_method(:current_subdomain) + end + +protected + + def current_subdomain + request.host.include?('localhost') ? request.subdomains(0).first : request.subdomains.first + end + +end \ No newline at end of file