<commit_before>class PasswordResetsController < ApplicationController
  
  before_filter :assign_password_reset, :only => [:edit, :update]
  
  def new
    @password_reset = PasswordReset.new
  end                              
                                   
  def create                       
    @password_reset = PasswordReset.new(params[:password_reset])
    if @password_reset.match_identifier? && @password_reset.save
      @password_reset.send_password_reset ### PROBLEM IS RIGHT HERE!!
      redirect_to root_url, :notice => "Email sent with password reset instructions."
    else
      redirect_to new_password_reset_path, :alert => "Could not find a user to match :("
    end
  end

  def edit
    if @password_reset.expired?
      redirect_to new_password_reset_path, :alert => "Password reset has expired"
    end
  end

  def update
    if @password_reset.update_user_password(params[:password_reset][:password], params[:password_reset][:password_confirmation])
      session[:user_id] = @password_reset.user.id
      redirect_to root_url, :notice => "Password has been reset, hurray!"
    else
      render :edit
    end
  end

  private
  def assign_password_reset
    @password_reset = PasswordReset.find_by_reset_token(params[:id])
  end
  
end<commit_msg>fixed update bug<commit_after>class PasswordResetsController < ApplicationController
  
  
  def new
    @password_reset = PasswordReset.new
  end                              
                                   
  def create                       
    @password_reset = PasswordReset.new(params[:password_reset])
    if @password_reset.match_identifier? && @password_reset.save
      @password_reset.send_password_reset
      redirect_to root_url, :notice => "Email sent with password reset instructions."
    else
      redirect_to new_password_reset_path, :alert => "Could not find a user to match :("
    end
  end

  def edit
    @password_reset = PasswordReset.find_by_reset_token(params[:id])
    if @password_reset.expired?
      redirect_to new_password_reset_path, :alert => "Password reset has expired"
    end
  end

  def update
    @password_reset = PasswordReset.find(params[:id])
    if @password_reset.update_user_password(params[:password_reset][:password], params[:password_reset][:password_confirmation])
      session[:user_id] = @password_reset.user.id
      redirect_to root_url, :notice => "Password has been reset, hurray!"
    else
      render :edit
    end
  end
  
end
{'fraction_non_alphanumeric': 0.08117932148626818, 'fraction_numerical': 0.0, 'mean_word_length': 2.9379968203497615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3823763', 'n_tokens_mistral': 710, 'n_tokens_neox': 688, 'n_words': 164}