user1946705
user1946705

Reputation: 2888

Rails 3 - routing, more parameters

I am thinking about the solution of variable count parameters in URL. In routes.rb I have following

match ":a(/:b)" => "home#bla"

This mean I can have in URL web.com/me, web.com/me/about-me or web.com/me/contact. I would need to add to URL this: web.com/me/one-thing/second-thing => if will be in URL the second parameter one-thing (exactly this string), so then must be there the third parameter (and know on the position of third parameter could be whatever, but always something).

I tried to edit routes.rb* with a following way:

match ":a(/:b/:c)" => "home#something" But this way is wrong...

Could anyone help me, please, how to edit my routes.rb for getting need effect? Thank you so much

Upvotes: 0

Views: 121

Answers (1)

iGEL
iGEL

Reputation: 17392

How about this?

match ":a(/:b(/:c))" => "home#something"

Otherwise you could do

match ":a(/:b)" => "home#something"
match ":a(/:b/:c)" => "home#something"

Upvotes: 2

Related Questions