Multiple domain names mapping to different rails app URLs

Am I on the right lines ?

Owain,

Thanks so much for this - it’s working! Lots of work now for me to clean
up, refactor (to use a posh word). I’ll write back later with a brief
summary for others if it helps but basically you got it.

Thanks so much.

bb

On Oct 26, 9:49am, bingo bob [email protected] wrote:

Inline - I won’t have a chance to test this out until a little later but
yes - thanks for this, think I’m getting it.

Me too. I was out all day yesterday.

at present these lines…

map.contacts ‘/contacts’, :controller => ‘properties’, :action =>
‘contacts’

exactly. since your properties controller already has access to the
@domain.property or @property from the before_filter. Therefore no
need to pick it up from the params[:id] at all.

so you should have a in routes.rb
map.root :controller => “properties”
this will mean that a call to http://chalet.com will invoke the index
action of the properties controller. Your index action should simply
call render :action => :details template to show the @domain.property
or whatever the template uses.

I guess you probably want to have a “master domain” that lists all of
the properties and still use the same app. Also for your admin
support. Well it is easy to amend your before_filter to handle a non-
defined domain and then tweak the index action to render
appropriately.

if @property
render :action => :details
else
render :action => :index
end

Your routes do need a bit of cleaning up. In fact you should look
RESTful routes. e.g. map.resources :availability I guess you have a
pretty big properties controller, try and keep them skinny and
delegate the stuff about availability to the availability
controller.

  • apache is doing some redirects here. You shouldn’t need any other
    than the no-www stuff. Take them out. Let rails do the routing. You
    only really need mod_rewrite if you are doing URL rewriting which I
    don’t think you need.

OK - I thought I just had the no-www stuff in there - but ok.

I was getting a 302 redirect for some reason. Make sure you have
removed any of the URL rewriting you were doing.

Hope that helps.

O.