簡體   English   中英

用戶編輯密碼后,Rails Devise重定向

[英]Rails Devise redirect after User edits their password

用戶嘗試根據設計文檔上的指南更改密碼后,嘗試更改路徑: 自定義重定向后的用戶編輯其配置文件

現在,我知道我必須創建自己的RegistrationController

class RegistrationsController < Devise::RegistrationsController
  protected
  def after_update_path_for(resource)
    user_path(resource)
  end
end

並將路徑更改為

def after_update_path_for(resource)
  dashboard_path
end

我創建了注冊模型

rails g controller Registrations  

並將其移至app / controllers文件夾

現在它說我也應該配置路由

devise_for :users, :controllers => { :registrations => :registrations }

我不太喜歡這樣編寫路由,因為我僅使用資源:,所以我嘗試了

devise_for :users, :controllers => { :registrations => 'dashboard#show' }

這給了我錯誤:

'dashboards#show' is not a supported controller name. This can lead to potential routing problems.

我不太清楚如何正確編寫路由才能將路徑更改為dashboard_path。

我什至可以正確生成控制器嗎?

您可以使用redirect_to root_path並在〜/ config / routes.rb中定義根。

您可以通過鍵入root 'dashboard#show' (或更傳統地) root 'dashboard#index'來定義根路徑。

暫無
暫無

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

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