Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First working prototype, grabs current subdomain, is smart enough to …
…know when you're running a localhost copy and will use the correct call to request.subdomains
- Loading branch information
Jose Fernandez
committed
May 2, 2008
1 parent
00f439c
commit 4084115
Showing
3 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
# Include hook code here | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |