0

I am new to ruby and rails. Here in routes.rb i have added the following line:

match 'check/' => "home#index"

When i hit url with server running on port 3000:

localhost:3000/check/

it works fine, but if i give url

localhost:3000/////////////////check////////////////////

it also works fine which should not be the case. With url

localhost:3000/////////////check////d//////

it says

No route matches [GET] "/check/d"

It means it is escaping slashes, why this is happening and how to resolve it. Also help me to know if we can make urls using regular exressions on rails.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
Paritosh Singh
  • 6,288
  • 5
  • 37
  • 56

1 Answers1

1

Regarding regular expressions in routes:

match '/:id' => 'posts#show', :constraints => {:id => /^\d/}

Will put a constraint on the id to be only digits.

Erez Rabih
  • 15,562
  • 3
  • 47
  • 64