Topic: Conditional Routes in routes.rb

Hey everybody,

we are hosting two domains from a single application (lets say and What we are trying to do is to have different name routes in both domains?

For example:  (in view we are calling posts_path) (in view we are calling posts_path)

but it will show the same results on both domains.

I've found these articles covering this problem: … g-in-rails … n-hostname

OUR routes.rb file looks like this:

map.resources :posts, :as => "entries", :conditions => {:domain => ''}
map.resources :posts, :as => "articles", :conditions => {:domain => ''}

If I call posts_path on  everything is fine and the route generated is
but if I call posts_path from   route generated is

(Routing Error - No route matches "/entries"  with {:subdomain=>nil, :request_uri=>"/entries", :remote_ip=>"xx.xx.xx.xx", :protocol=>"http://", :content_type=>nil, :host=>"", :accepts=>"text/html,application/xml,*/*", :method=>:get, :domain=>"", :port=>3000})

it should be

We can't figure out why the second ':as' parameter was ignored even when the domain is and conditions is satisfied.

Any help would be much appreciated!

Cheers Pete

Re: Conditional Routes in routes.rb

What does your log say? I'm not sure if you're in production or not with this app yet, but if it's still in development mode, then take a look at the development.log in the log directory of your Rails app.

Re: Conditional Routes in routes.rb

Also, paste the results of "rake routes".