ruby on rails - Updating Strong Params Only -


first of all, believe there must people, asked question before don't know how can google problem. so, if duplicate sorry.

i working on social media site. have user model, use register users site. validates, name, email, , password when registering.

i use same model make users edit informations, username.

this have in update controller:

  def update     # find existing object using form parameters     @profile = user.find_by_id(current_user.id)     # update object     if @profile.update_attributes!(settings_profile_params)       # if save succeeds, redirect       redirect_to request.referrer     else       # if save fails, redisplay form user can fix problems       render('edit')     end   end    private # user_params not action, why private.   def settings_profile_params     params.require(:user).permit(:first_name, :last_name, :username, :school, :program, :website, :information)   end 

the problem is, want update strong parameters defined there. getting exception because of password validation. don't know why getting exception. how can set system update values in strong parameter only.

thank you.

you can achieve changing password validation. need add condition on password validation.

# password   validates :password,             :presence => {:message => 'password cannot blank'},             :length => {:within => 8..99, :message => 'password length should within 8 , 99 characters'}             :if => proc.new { new_record? || !password.nil? } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -