# Routing Resources to two different places

**URL:** <https://www.ruby-forum.com/t/routing-resources-to-two-different-places/109031>\
**Category:** Rails\
**Created:** [July 10, 2007, 7:06pm UTC](https://www.ruby-forum.com/t/routing-resources-to-two-different-places/109031 "2007-07-10T19:06:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brent\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@Brent\_D](https://www.ruby-forum.com/u/Brent_D)\
**Post date:** [July 10, 2007, 7:06pm UTC](https://www.ruby-forum.com/t/routing-resources-to-two-different-places/109031/1 "2007-07-10T19:06:18Z")

</div>

Hi folks,

Here’s the deal:

I’ve got an Article model and an ArticlesController with a set of  
templates that I like so much, I need to share it with different parts  
of the site which have different URL’s. I’m using REST for the  
articles.

So at the top-level of the site, I might have something like:

# [http://example.com/news/articles](http://example.com/news/articles)

map.resources :articles, :path\_prefix =\> “news”

I also have many “subsites” of my domain which need news articles,  
too:

# [http://example.com/example\_subsite/news/articles](http://example.com/example_subsite/news/articles)

map.resources :articles, :path\_prefix =\> “:subsite/news”, :name\_prefix  
=\> “subsite\_”

So, yeah, this would work out OK. But this means that in my Article  
templates when I’m calling the named routes, I’d probably have to make  
a helper method like:

def article\_path\_helper(path, subsite = false)  
if subsite  
send(‘subsite\_’ + path, :subsite =\> subsite)  
else  
path  
end  
end

So as an example in my Article templates:  
article\_path\_helper(‘edit\_article\_path’, @subsite)

@subsite would get set by some logic in the controller if we’re routed  
from a subsite URL, otherwise it’s false.

Maybe it’s my inexperience, but this seems dirty and like I’m doing  
something wrong. Are the named routes provided by the REST stuff worth  
using in this case? Maybe I should ignore the named routes and use  
url\_for instead, if that would make things any easier… not sure.

I tried to keep this brief, but can elaborate if needed… hope it’s  
clear enough. I’d love to have anyone’s thoughts on solving this  
particular problem.
