我在注册路径中设置了一个可选的参数:
devise_scope :user do
get '/signin', to: 'devise/sessions#new'
get '/signup(/:sign_up_key)', to: 'users/registrations#new'
end
在可选参数之前,我可以做到:
signup_path
机架路线显示:
signin GET /signin(.:format) devise/sessions#new
GET /signup(/:sign_up_key)(.:format) users/registrations#new
现在signup_path
已不再可用?如何使用可选参数将其恢复?
顺便说一下,我这样路由:
<%= link_to '/signup' ... %>
而不是:
<%= link_to signup_path ... %>
想获得前缀的访问权限吗?谢谢!
答案 0 :(得分:2)
尝试添加as: :singup
:
get '/signup(/:sign_up_key)', to: 'users/registrations#new', as: :signup