我有以下问题,我不明白为什么它不起作用:
我有路线:
get "/:id" => 'landings#show_direct', as: :direct_landing, id: /ticket-from-[a-zA-Z0-9_]+/
get "/:id" => 'landings#show_reverse', as: :reverse_landing, id: /ticket-to-[a-zA-Z0-9_]+/
它工作正常
localhost:3000/ticket-form-moscow
localhost:3000/ticket-to-moscow
耙路线 | grep 登陆
direct_landing GET /:id(.:format) landings#show_direct {:id=>/ticket-from-[a-zA-Z0-9_]+/}
reverse_landing GET /:id(.:format) landings#show_reverse {:id=>/ticket-to-[a-zA-Z0-9_]+/}
但是当我尝试建立链接时
= link_to @landing.title_to, reverse_landing_url('ticket-to-moscow')
我有错误信息
No route matches {:action=>"show_reverse", :controller=>"landings", :id=>"ticket-to-moscow", :format=>nil} missing required keys: [:id]
任何想法我做错了什么?