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
Post a Comment