V
V
vadimstroganov2016-02-07 00:56:03
Ruby on Rails
vadimstroganov, 2016-02-07 00:56:03

How to make a mass update of parameters with validation?

I update the user fields, but with such an update, data validation does not occur

def update
  if @current_user.update_attributes(user_params_for_update)
     respond_200
  else
     render json: ErrorSerializer.serialize(@current_user.errors), status: :unprocessable_entity
  end
end

Is it possible to somehow enable validation using the update_attributes method? Or is there some other way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Pyankov, 2016-02-07
@vadimstroganov

You can use `update`. Here is another useful link on the topic: www.davidverhasselt.com/set-attributes-in-activerecord

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question