ruby on rails - 重置密码 - 覆盖

时间:2018-05-20 13:12:07

标签: ruby-on-rails ruby-on-rails-4 devise reset-password

我在rails版本4.2.4上使用ruby并设计4.0.0

我有重置密码的问题,我试图覆盖并重置为新密码,通过覆盖设计自己。现在我有了更改密码的代码,我需要完成"更新"功能

以下是我的代码,以覆盖Devise :: PasswordsController

在route.rb中:

devise_for :users, controllers: { passwords: 'users/passwords' }

在controller / users / password_controller.rb

class Users::PasswordsController < Devise::PasswordsController

    def create
        super
        puts "create PasswordsController"
    end

    def new
        super
        puts "new PasswordsController"
    end

    def update

        reset_password_token_hash = Devise.token_generator.digest(self, :reset_password_token, resource_params['reset_password_token']) 
        user = User.find_by_reset_password_token(reset_password_token_hash)
        user.update(password: resource_params['password'])  
        #xxxx respond_with resource, needs to do something like this ??


    end

    def edit
        super
        puts "edit PasswordsController"
    end
end

它设法更改密码,但页面有问题:

Completed 500 Internal Server Error in 176ms (ActiveRecord: 13.0ms)

ActionView::MissingTemplate - Missing template users/passwords/update, users/passwords/update, devise/passwords/update, devise/update, application/update with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :slim, :jbuilder]}. Searched in:
  * "/Users/megasap/Documents/project/harta.org/harta.org-backend/app/views"
  * "/Library/Ruby/Gems/2.3.0/gems/ckeditor-4.2.2/app/views"
  * "/Library/Ruby/Gems/2.3.0/gems/grape-swagger-rails-0.2.0/app/views"
  * "/Library/Ruby/Gems/2.3.0/gems/devise-4.0.0/app/views"

有人可以告诉我如何完成&#34;更新&#34;用户的方法:: PasswordsController

0 个答案:

没有答案