Refactor away nested if statement in Associations#detect_conditions_option