Skip to content

Instantly share code, notes, and snippets.

@thechrisoshow
Created August 16, 2011 10:43
Show Gist options
  • Save thechrisoshow/1148835 to your computer and use it in GitHub Desktop.
Save thechrisoshow/1148835 to your computer and use it in GitHub Desktop.
How should I white label a Rails app?
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
@thechrisoshow
Copy link
Author

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