Clean up SQL code for Associatable#has_one_through