Created
September 11, 2022 15:35
-
-
Save tanhit243/ade17417bf5d360024c8b06561855678 to your computer and use it in GitHub Desktop.
Tìm kiếm route trong rails với route -g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:info_neon: Chuyên mục MIL - Monday I learn - 003 | |
Số MIL-002 đã giới thiệu về một hàm mới họ *sole | |
Vì thấy mọi người hay dùng VS code nên chắc hẳn việc tìm route trong một dự án lớn là khá vất vả. Số này mình xin giới thiệu một option trong rails routes rất hữu ích đó là -g. Đến bây giờ mới biết vì trước đó mình dùng rails routes | grep ..., cách này vẫn ổn nhưng dài hơn so với các sử dụng option. | |
Trước rails 7: Bạn chỉ có thể tìm kiếm được dạng rails routes -g users/:user_id/posts/:post_id hoặc rails routes -g users | |
Sau rails 7 (> 7.0.3): | |
Bạn có thể sử dụng path dễ hiểu hơn là rails routes -g users/1/posts/1. Chúng ta không phải nhớ chính xác tên symbol trong route. | |
Tham khảo: | |
https://blog.saeloun.com/2022/09/06/extend-routes-grep-functionality | |
https://github.com/rails/rails/pull/45874 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment