I am using JS sorting to call this method:
def sort
params[:piece].each_with_index do |id, index|
current_user.lineup.piece_lineups.update_all({position: index+1}, {piece_id: id})
end
render nothing: true
end
and in my piece_lineup model I have:
after_update :update_associated_lineup
however it isn’t getting triggered by that update_all call. am i doing something wrong?
update_allmethod generates one SQL UPDATE query and that’s all. It doesn’t instantiate any ActiveRecord objects, so no validations or callbacks are triggered. To trigger callbacks you have to do something like that