簡體   English   中英

在rake路線中未顯示的自定義編輯操作的rails參考是什么

[英]What is the rails reference for a custom edit action not showing in rake routes

我有一個password_resets控制器,並且我想使URL僅用於編輯操作。

這是在我的路線文件中:

  get     'resetpassword/:id/edit'  => 'password_resets#edit'

我已經測試過並且可以使用! 困難的是,現在我不知道如何訪問它。

我的垃圾箱/耙線路線如下所示:

         forgotpassword GET    /forgotpassword(.:format)                   password_resets#new
                        GET    /resetpassword/:id/edit(.:format)           password_resets#edit
        password_resets POST   /password_resets(.:format)                  password_resets#create
     new_password_reset GET    /password_resets/new(.:format)              password_resets#new
    edit_password_reset GET    /password_resets/:id/edit(.:format)         password_resets#edit
         password_reset PATCH  /password_resets/:id(.:format)              password_resets#update
                        PUT    /password_resets/:id(.:format)              password_resets#update

即,我的自定義URL沒有前綴。 那么如何在代碼中訪問它呢?

這就是我在代碼中可以使用的但不使用自定義網址的內容。

<%= edit_password_reset_url(@user.reset_token, email: @user.email) %>

您需要命名您的路線:

get  'resetpassword/:id/edit'  => 'password_resets#edit', as: :reset_password_pretty

有相應的指南: http : //guides.rubyonrails.org/routing.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM