6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/concerns/spree/api/v2/platform/nested_set_reposition_concern.rb', line 6
def reposition
spree_authorize! :update, resource if spree_current_user.present?
@new_parent = scope.find(permitted_resource_params[:new_parent_id])
new_index = permitted_resource_params[:new_position_idx].to_i
if resource.move_to_child_with_index(@new_parent, new_index)
successful_reposition_actions
elsif resource.errors.any?
render_error_payload(resource.errors.full_messages.to_sentence)
else
render_serialized_payload { serialize_resource(resource) }
end
end
|