Jasjeet Singh
Jasjeet Singh

Reputation: 338

Devise: How to skip email validation while updating a user information?

How can I skip email validation while updating a user info? As I skip presence validation at time of creating a new User. When I try to update information of that User it sends me an error in response.

{
 "code": 200,
  "status": "ERROR",
  "errors": {
    "email": [
      "can't be blank"
    ]
  }
}

Upvotes: 0

Views: 239

Answers (1)

Elis Bresciani
Elis Bresciani

Reputation: 116

I was having this problem but with the password. I managed to solve it like this:

def update
 respond_to do |format|
  if @user.update(user_params.except(:password, :password_confirmation))
    format.html { redirect_to @user,  :flash => :success  }
    format.json { render :show, status: :ok, location: @user }
  else
    format.html { render :edit }
    format.json { render json: @user.errors, status: :unprocessable_entity }
  end
 end
end

you can try except the email, but its stanger.

Upvotes: 1

Related Questions