views:

79

answers:

1

I am trying to set the following up:

www.domain.com goes to the main site (user can register, information about application)

foo.domain.com goes to the main application that is customized to the user(subdomain)

what is the best way to separate the rails parts? Namespaced controllers seem frowned upon.

A: 

Don't separate them. Just use a before_filter to require login and a subdomain on the controllers that requires a subdomain/client to be present.

class ApplicationController < ActionController::Base
  private

  def require_subdomain_scope
    # check if request.subdomains is blank or www. Something like that.
  end
end

class StaticPagesController < ApplicationController
  # no before_filter!
end

class ProjectsController < ApplicationController
  before_filter :require_login, :require_subdomain_scope
end
August Lilleaas