ruby on rails devise skip validation of password, when edit user in user form



If you want to skip password validation in devise login. In users controller, you only add line below:


sign_in @user, :bypass => true unless params[:user][:password].blank?

for example:
def update
    if @user.update_user_data(params[:user])
      sign_in @user, :bypass => true unless params[:user][:password].blank?
      if current_user.is_admin?
        redirect_to users_path
      else
        redirect_to edit_user_path(current_user)
      end
    else
      render :action => :edit
    end
  end



Komentar

Postingan populer dari blog ini

EPrT English Proficiency Test Soal - soal

cara memunculkan dan menyembunyikan icon date, time, clock, volume, network, power battery, action center pada taskbar pada Windows 7

Cara Mengurus Perpanjang SIM dan Rincian Biaya di Lumajang.