Forum: Ruby on Rails custom routes, you need string literals correct? when using

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.
3d1a70ebd35ac970e009e01599603b46?d=identicon&s=25 koloa (Guest)
on 2007-02-23 15:14
more than 1 route that contains the same number of arguments?
C7e57d61d3af14a5c2552df766a8e531?d=identicon&s=25 kreiggers (Guest)
on 2007-02-23 20:49
(Received via mailing list)
On Feb 23, 6:14 am, koloa <rails-mailing-l...@andreas-s.net> wrote:
> more than 1 route that contains the same number of arguments?

I think you mean if you have two routes like this:

/:arg1/:arg2/:id
/:arg3/:arg4/:id

then yes Rails needs some why to differentiate these like:

/foo/:arg1/:arg2/:id
/bar/:arg3/:arg4/:id

But don't forget that you can also differentiate with regex patterns
if your args are distinguishable by pattern like

/:arg1/:arg2/:id   :requirements => { :arg1 => /\d[A-Z]\d/  }
/:arg3/:arg4/:id   :requirements => { :arg3 => /[a-z]\d[a-z]/ }

The first would match something like '/2D4/anything/12' and the second
would match '/a5d/anything/12' and could be routed different ways.
This topic is locked and can not be replied to.