我想創建一個用戶“個人資料頁面”,其中包含指向其他頁面的鏈接,他們可以在其中更新其帳戶資訊。不幸的是,帶有設計的開箱即用的默認“編輯”頁面不足以滿足我的需要。
例如,我希望它的路線看起來像這樣:
'/profile'
'/profile/edit' <-- this would be the default devise edit password, name etc.
'/profile/documents'
'/profile/progress'
但是我不確定在使用 Devise 時如何處理這個問題。我已經有了開箱即用的設計,帶有默認的編輯頁面,但我本質上只是想為用戶添加額外的視圖來上傳檔案等。
對此的任何幫助將不勝感激!
uj5u.com熱心網友回復:
可以有兩種解決方案:
第一的:
使用 Devise,您可以自定義控制器/視圖:
例如,在您的情況下,您將在您的routes.rb:
devise_for :users, controllers: {registrations: 'profiles'}
簡單來說,這將告訴設計將組態檔控制器設定為注冊控制器。
您可以通過此設計自述檔案部分了解更多詳細資訊。
第二:
如果您不想撰寫自定義控制器并將表單擴展到新欄位,那么您可以簡單地registrations/edit.html.erb使用新欄位(如影像上傳等)編輯頁面并將這些附加引數列入白名單/允許在您的ApplicationController:
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
# for signup
devise_parameter_sanitizer.permit(:sign_up, keys: [:image])
# for update
devise_parameter_sanitizer.permit(:account_update, keys: [:image])
end
end
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/409033.html
標籤:
上一篇:Swift:當弱自我為零時,完成閉包是否應該有錯誤指示?
下一篇:如何使用字串函式從向量中提取日期
