# Routes in Engines

**URL:** <https://www.ruby-forum.com/t/routes-in-engines/54639>\
**Category:** Engines Development\
**Created:** [March 10, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/routes-in-engines/54639 "2006-03-10T19:42:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [March 10, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/routes-in-engines/54639/1 "2006-03-10T19:42:19Z")

</div>

I had remembered pondering this myself, and it is likely that several  
others  
may have as well.

I haven’t tested this yet, but I am under the impression throwing this  
inside of a /vendor/plugins/my\_engine/lib/routes.rb, very well may work.

It would be great to create an abstract layer ontop of the Rails engines  
to  
define new routes. Such as:

Engines.map.connect “#{ADMIN\_PAGE\_DIR}/\*name”,  
:controller=\>‘view\_pages’,  
:action=\>‘show\_page’

Here is the snippet:

ActionController::Routing::Routes.draw do |map| map.connect  
“#{ADMIN\_PAGE\_DIR}/\*name”, :controller=\>‘view\_pages’,  
:action=\>'show\_page ’  
map.connect ‘’, :controller =\> “admin\_pages”, :action=\>“edit\_pages”  
map.connect ‘:controller/service.wsdl’, :action =\> ‘wsdl’  
map.connect ‘:controller/:action/:id’  
end

Has anyone else done something like this yet? I think the biggest  
advantage  
to this is doing some new hacks on the ActionController::Routing::Routes  
to  
add domain wildcards. So those who are doing [username.example.com](http://username.example.com), can  
automatically route it to the specific controller and action.

I will be embarking on this sooner or later, but would be nice to see  
who  
else has done what.

-Nb

```auto
 Nathaniel S. H. Brown http://nshb.net

```

---

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [March 17, 2006, 1:55am UTC](https://www.ruby-forum.com/t/routes-in-engines/54639/2 "2006-03-17T01:55:25Z")

</div>

I’ve been thinking about this myself, but I haven’t done anything yet.  
Actually, I played with it a little today, but nothing really  
productive come of it.

My reason for doing so is to remove the need to add anything to  
config/routes.rb, but also somehow allowing you to overwrite the  
engine defaults if you want, or not having them at all. Seems a bit  
challenging.

-jeff

On 3/10/06, Nathaniel S. H. Brown [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> :action=\>‘show\_page’  
> Has anyone else done something like this yet? I think the biggest advantage  
> Nathaniel S. H. Brown [http://nshb.net](http://nshb.net)
> 
> ```auto
> 
> _______________________________________________
> engine-developers mailing list
> removed_email_address@domain.invalid
> http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org
> 
> ```

–  
Jeff L.  
[http://blogrium.com/](http://blogrium.com/)
