2017-05-30 59 views
1

我在Rails应用程序中使用Devise进行身份验证。包括重置密码邮件程序等在内的密码管理通过派生于Devise :: PasswordsController的控制器进行处理。例如:Rails:使用自定义URL进行密码重设Devise

class Users::PasswordsController < Devise::PasswordsController 
    def new 
    if not set_actionmailer_settings 
     error = I18n.t('invalid_paswd_config') 
     redirect_to new_user_session_path, 
        :flash => { :error => error } and return 
    end 

    super 
    end 
end 

我现在已经转移到不使用Rails UI的新UI。相反,它会调用Rails API。在发送给用户重置密码的电子邮件中,如果我想要使用自定义密码重置URL,我该怎么做?

回答

1

试试这个在您的routes.rb

map.devise_for :users, controllers: {passwords: "users/passwords"}, path_names: { 
    new: :new 
} 
+0

我在哪里指定自定义网址?我不认为这回答了这个问题。 – CppNoob

+0

自定义URL必须有一个'controller'和一个'action',你必须在那里替换.. –

相关问题