Slide 52
Slide 52 text
仕様書とソースコードの食い違いの例 For example
Rails 2でGETとPOSTを区別しない書き方をしていた
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
In Rails 2, the code did not
distinguish between GET and
POST.
The specification listed GET, so we
changed the code to GET only.
仕様書にはGETと書かれていたのでGETに修正した
In practice, some clients were
get ':controller(/:action(/:id))'
calling the endpoint with POST or
get ':controller(/:action(/:id(.:format)))'
PATCH.
実際にはPOSTやPATCHで叩いてくるクライアントが存在した
仕様はGETのみだがPOSTを塞いでいなかったため、
制限すると既存クライアントが接続できなくなる
→ 仕様書のほうを修正した
The specification allowed only GET,
but POST was not blocked;
restricting it would have broken
existing clients — so we updated
the specification instead.
match ':controller(/:action(/:id))', via: [:get, :post, :patch]
match ':controller(/:action(/:id(.:format)))', via: [:get, :post, :patch]
© 2019-2026 OPTiM Corp. All rights reserved.
52