Your customer is going to need to set up DNS For their domain to point it, or part of it, to your address. This can be tricky to coordinate, especially if the address of the server you're hosting the service on can change from time to time. It's a lot easier to route a customer's subdomain to your subdomain.
You'll also need a lookup table that maps a customer's domain to a customer's account. That's typically expressed as something like this:
before_filter :load_customer_from_host
def load_customer_from_host
# Strip "www." from host name to search only by domain.
hostname = request.host.sub(/^www\./, '')
@customer = Customer.find_by_host!(hostname)
rescue ActiveRecord::RecordNotFound
render(:partial => 'customer_not_found', :layout => 'application', :status => :not_found)
end
That presumes you have a Customer model with a 'host' field set with something like 'customer1.myapp.com' or 'customer1.com', whatever matches the host field.
When you set up your app, you will need to have a virtual host configuration that responds to all arbitrary domain names. This is easy to do if it is the only site hosted, since that is the default behaviour. If you're doing this on shared hosting you may have to configure an alias for each customer domain specifically, which can be a nuisance.