Forum: Ruby on Rails CMS-like routing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bbe2b1d89381c0b7f728fe339e19153b?d=identicon&s=25 Frank Wittmann (lakitu)
on 2006-02-14 16:49
I'd like to set up routes like /<section>/<article>. Using a route like
map.connect ':section/:article' works just fine, but I've also got an
admin area that is accessed through the route 'admin'.

Inside the admin area I've got subpages like admin/sections and
admin/articles. This is conflicting with the other routes and I'm not
able to write something like map.connect 'admin/:section', :controller
=> 'admin/:section'.

Any suggestions on this?
Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-02-14 17:22
(Received via mailing list)
Yep, I have my 'cms' like tool setup to do just that. The only way I
got around it is kind of fugly, but it works.

Heres what I have for some map entries..

#map to make sure that all the controllers that need be accessed are
able to, and not
   #treated as "pages" in the cms
   map.connect ":controller/:action/:id" , :requirements => {
:controller => /admin|any|other|controllers|here/ }

  map.page ":path/:page", :controller => 'page', :action => 'view'

Basically I have one controller (pages_controller) that the
users/viewers of the site access and controls the display of the
pages. In your case it would be :sections/:articles but you get the
point.

Also, the order is important! The normal map needs to be above your
section/article map.

Hope this helps!
-Nick
82476266af9d460415d8f1fc16bb54ed?d=identicon&s=25 Jarkko Laine (jarkko)
on 2006-02-15 09:31
(Received via mailing list)
On 14.2.2006, at 17.49, Frank Wittmann wrote:

> Any suggestions on this?
If you put the admin route before the standard one, everything should
work just fine.

Routes are always matched in the order they appear in routes.rb.

//jarkko

--
Jarkko Laine
http://jlaine.net
http://odesign.fi
This topic is locked and can not be replied to.