Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RubyonRails重命名的变量测试仍然可以看到以前的名称_Ruby On Rails_Ruby_Testing_Rename_Bcrypt - Fatal编程技术网

Ruby on rails RubyonRails重命名的变量测试仍然可以看到以前的名称

Ruby on rails RubyonRails重命名的变量测试仍然可以看到以前的名称,ruby-on-rails,ruby,testing,rename,bcrypt,Ruby On Rails,Ruby,Testing,Rename,Bcrypt,为了让我的专栏有更友好的名字,我运行了以下迁移: class RenameDigestColumnsOnUserToEncryptedTokens < ActiveRecord::Migration[5.0] def change rename_column :users, :password_digest, :encrypted_password rename_column :users, :activation_digest, :encrypted_activati

为了让我的专栏有更友好的名字,我运行了以下迁移:

class RenameDigestColumnsOnUserToEncryptedTokens < ActiveRecord::Migration[5.0]
  def change
    rename_column :users, :password_digest, :encrypted_password
    rename_column :users, :activation_digest, :encrypted_activation_token
    rename_column :users, :reset_digest, :encrypted_reset_password_token
  end
end
以及相关的登录方法:

# Logs in the given user.
  def log_in(user)
    session[:user_id] = user.id
  end
我尝试重新启动spring,甚至重新启动计算机,我看不出它来自何处,计算机如何仍然可以看到这些名称

我正在使用bcrypt gem生成加密令牌,以前用digest命名,这就是我试图重命名的令牌


有人有过这个问题吗?提前感谢您的帮助。

如果您看到关于密码摘要列的错误,可能您正在使用Active record has\u secure\u password,该列要求:

您是否在测试环境中运行迁移<代码>bundle exec rake db:migrate RAILS_ENV=test是的,我重置了开发数据库,我的应用程序与测试有相同的问题,它查找以前的名称,所以它不再工作了。你能发布
password\u resets\u controller.rb
更新操作吗?我编辑了以下问题:)password\u resets\u controller.rb:29上的第29行是哪一行?实际上,我从我的项目中删除了designe来创建我自己的身份验证系统,并且它工作得很好,直到这次重命名…同样的事情,我删除了一个\u secure\u密码,以便在我自己的基础上构建并自定义它:)嗯,刚刚发现我重新激活了它,我不知道如何激活,所以这就是问题的原因,谢谢您的帮助:)
def update
    if params[:user][:password].empty?
      @user.errors.add(:password, "can't be empty")
      render 'edit'
    elsif @user.update_attributes(user_params)
      log_in @user
      # to prevent, on a public machine for example, people from pressing the back button and changing
      # the password (and getting logged in to the site) whereas it's always been reset
      @user.update_attribute(:encrypted_reset_password_token, nil)
      flash[:success] = 'Password has been reset.'
      redirect_to @user
    else
      render 'edit'
    end
  end
# Logs in the given user.
  def log_in(user)
    session[:user_id] = user.id
  end