Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top