Skip to content

Commit 7db96bc

Browse files
committed
Add a style guide to suggest to pass a string literal as a URL to http method calls
Original discussion: rubocop#328 Signed-off-by: moznion <[email protected]>
1 parent 524a1ac commit 7db96bc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,23 @@ match ':controller(/:action(/:id(.:format)))'
231231

232232
Don't use `match` to define any routes unless there is need to map multiple request types among `[:get, :post, :patch, :put, :delete]` to a single action using `:via` option.
233233

234+
=== HTTP URL [[http-url]]
235+
236+
Prefer passing a string literal as a URL to HTTP methods to make the actual URL obvious and to facilitate tracking endpoint path changes.
237+
238+
[source,ruby]
239+
----
240+
# bad
241+
get photos_path
242+
put photo_path(id)
243+
post edit_photo_path(id)
244+
245+
# good
246+
get "/photos"
247+
put "/photos/#{id}"
248+
post "/photos/#{id}/edit"
249+
----
250+
234251
== Controllers
235252

236253
=== Skinny Controllers [[skinny-controllers]]

0 commit comments

Comments
 (0)