routing error with :username in url

后端 未结 1 1033
再見小時候
再見小時候 2021-01-06 12:18

I have a Rails 3 question. I want to get my users controller show page to have the app.com/people/username url.

Route

resources :users  
match \"/peo         


        
相关标签:
1条回答
  • 2021-01-06 13:10

    I don't think starting with . is supported by default in rails routes. You can do something like

    match "/people/:username" => 'users#show', :as => :profile, :username => /[\.a-zA-Z0-9_]+/
    

    The above regex will match ., a-z, A-Z, 0-9 and _ as valid characters for the username.

    0 讨论(0)
提交回复
热议问题