if params[:parent_type] == "Order"
parent_id = nil
else
parent_id = params[:parent_id]
end
Would a Ruby person laugh at me for writing it this way? It doesn't seem particularly concise like some Ruby code I've seen.
That looks perfectly reasonable to me. You could move the assignment in front of the if ( parent_id = if params...
) or use the ternary, but I don't think the result would look better.
If parent_id is nil or undefined before that line you can simply write:
parent_id = params[:parent_id] unless params[:parent_type] == "Order"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With