Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to map a full domain to a subdomain-based Rails app account?
    text
    copied!<p>I'm developing a Rails app that by default sets up user accounts to a subdomain of their choosing. As an option, they will be able to map their own full domain to their account.</p> <p>So far this is how I have things set up. I am using <a href="http://github.com/mbleigh/subdomain-fu" rel="nofollow noreferrer">subdomain-fu</a> to power the routing:</p> <pre><code># routes.rb map.with_options :conditions =&gt; {:subdomain =&gt; true} do |app| app.resources # User's application routes are all mapped here end map.with_options :conditions =&gt; {:subdomain =&gt; false} do |www| www.resources # Public-facing sales website routes are mapped here end </code></pre> <p>In addition to that, I am using the <a href="http://wgibbs.github.com/2008/05/11/domain-mapping.html" rel="nofollow noreferrer">method described here</a> to get the account being accessed, via subdomain or full domain:</p> <pre><code>before_filter :set_current_account def set_current_account if request.host.ends_with? current_domain # via subdomain @current_club = Club.find_by_subdomain(current_subdomain) else # via full domain @current_club = Club.find_by_mapped_domain(request.host) end end </code></pre> <p>I haven't got very far down the process of building this yet, but already I can see I am going to run into problems with routing. If <code>request.host</code> is some random.com domain then subdomain-fu is not going to route the appropriate routes?</p> <p>I'm assuming this isn't that unusual a problem, so can anyone share how they have tackled this problem, or how I would configure my routes to do what I need it to?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload