[問題] Ruby的Routes設定問題請教

看板Ruby作者 (郭郭)時間4年前 (2019/10/02 13:17), 編輯推噓2(2011)
留言13則, 4人參與, 4年前最新討論串1/1
Ruby 完全不熟 來請教各位大大 先謝謝各位了 就是假如我有設一條routes 網址是 localhost:3000/index 這樣子導向我期望的頁面OK了 但是如果是 localhost:3000/index.ewgwgw 就是index.後面亂加什麼東西也一樣會導至該頁面 該如何設定 只能符合index這字樣才轉到該頁面 Rails版本是 3.2.9 Ruby版本是 ruby 1.9.3p484 (2013-11-22 revision 43786) 感謝各位~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.130.182.55 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Ruby/M.1569993461.A.060.html

10/02 22:39, 4年前 , 1F
routes 後面加上 `:format => false`
10/02 22:39, 1F

10/02 22:40, 4年前 , 2F
或寫在 `scope(format: false){ }` block 裡面
10/02 22:40, 2F

10/03 00:18, 4年前 , 3F
樓上大神
10/03 00:18, 3F

10/07 09:51, 4年前 , 4F
感謝大神的回覆 但試了幾次還是無效果 不知道是不是設錯了
10/07 09:51, 4F

10/07 09:52, 4年前 , 5F
get "test/index"
10/07 09:52, 5F

10/07 09:53, 4年前 , 6F
match ':controller(/:action(/:id))(.:format)', :control
10/07 09:53, 6F

10/07 09:53, 4年前 , 7F
ler => /test\/[^\/]+/
10/07 09:53, 7F

10/07 09:54, 4年前 , 8F
看前人的設定是這樣 我在get "test/index"後面加或是match
10/07 09:54, 8F

10/07 09:55, 4年前 , 9F
後面增加 都還是會有一樣的問題
10/07 09:55, 9F

10/07 11:47, 4年前 , 10F
match ':controller(/:action(/:id))(.:format)', :c
10/07 11:47, 10F

10/07 11:47, 4年前 , 11F
ontrol 把(.:format) 拿掉就好
10/07 11:47, 11F

10/08 16:14, 4年前 , 12F
回P大 小弟把(.:format)拿掉以後還是一樣會連過去
10/08 16:14, 12F

10/09 13:44, 4年前 , 13F
Format 拿掉後面有加 format: false 嗎?
10/09 13:44, 13F
文章代碼(AID): #1Tb3Br1W (Ruby)