Rails Route URL segment with + (plus) sign character in id is not parsed correctly -


i have tagscontroller class, route following (in routes.rb)

resources :tags 

now, when go

http://localhost:3000/tags/test 

it works correctly.

however, when go to

http://localhost:3000/tags/c++ 

rails seems parsing "c++" "c ", results in "404 not found"

could give me instructions on how fix this?

for rails 4 rails provides constrain options determine regex parameter in routes:

this constrains allowing access param /photos/1 or /photos/rr27

resources :tags, constraints: { id: /[a-z][a-z][0-9]+/ } 

for advance constraint

by default :id parameter doesn't accept dots - because dot used separator formatted routes. if need use dot within :id add constraint overrides - example id: /[^/]+/ allows except slash.

resources :tags, constraints: { id: /[^\/]+/ } 

these details of specifying constraint routes. hope can you.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -