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 |
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?
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
What do you think of this approach?
The work happens in line #16 with prepend_view_path which will ensure a specific view path for white labelled sites. This will allow me to have different layouts/partials etc
Of course, it might be a bit hard out. I might be able to just do it all in CSS and include a special CSS file for white labelled sites.