我正在使用Devise
并更改其默认路由:
devise_for :users, :path => '',skip: [:sessions]
as :user do
get '/forgotten' => 'users/passwords#new', as: :password
post '/forgotten' => 'users/passwords#create'
put '/forgotten' => 'users/passwords#update'
get '/password/edit' => 'users/passwords#edit'
end
new.html.erb
生成的网址(表单操作属性)(使用新密码说明发送电子邮件的视图)为/forgotten.user
,这是不正确的。正确的URL是/forgotten
,它与不同的HTTP动词GET / POST / PUT一起使用。
请求新密码表单(new.html.erb):
<%= form_for(resource, as: resource_name,
url: password_path(resource_name), html: { method: :post})
如果没有rake routes
的自定义路线,我会看到以下路线:
user_password |补丁| /password(.:format)|用户/密码#更新
PUT | /password(.:format)|用户/密码#更新
POST | /password(.:format)|用户/密码#创建
如何使此路由自定义并用于不同的HTTP谓词?
答案 0 :(得分:0)
尝试删除as :user do
get '/forgotten' => 'users/passwords#new', as: :password
post '/forgotten' => 'users/passwords#create'
put '/forgotten' => 'users/passwords#update'
get '/password/edit' => 'users/passwords#edit'
如果您需要像/user/forgotten
那样使用scope 'user' do