Created
August 16, 2011 10:43
-
-
Save thechrisoshow/1148835 to your computer and use it in GitHub Desktop.
How should I white label a Rails app?
This file contains hidden or 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
class ApplicationController < ActionController::Base | |
around_filter :set_white_label | |
private | |
def set_white_label | |
subdomains = request.subdomains - RESERVED_SUBDOMAINS | |
if subdomains.empty? | |
yield | |
return | |
end | |
# Obviously extract this out to work with any subdomain we want | |
if subdomains.first == "mycompany" | |
white_label_view_path = File.expand_path(File.join(RAILS_ROOT, 'app', 'white_labels', "mycompany")) | |
prepend_view_path(white_label_view_path) | |
yield | |
end | |
end | |
end |
Only the ones you want to override. The idea is that it looks for the file in the requested path, and if it can't find it, looks in the standard dir structure.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like it. Does the prepend_view_path allow you to only override some view files or do you need to have a complete set in that directory structure?