Вопрос

I have this code reek complains for DuplicateMethodCall (calls format.json twice)

if object_error.blank?
  format.json { render json: order }
else
  format.json { render json: object_error, status: :unprocessable_entity }
end

What is the best way to do it in rails? or is this false positive?

Это было полезно?

Решение

I think there is no need in refactoring in this particular case.

This, and other variations occurs errors too:

format.json { render(object_error.blank? ? (json: order) : (json: object_error, status: :unprocessable_entity) }

And it's less readable.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top