# Theres Good Clever, and Bad Clever

Written by Piers Cawley on

Have you noticed the difference between Good Clever and Bad Clever?

For instance, I recently spent a couple of hours working out to make a Genre model which acts_as_nested_list work in such a way that when ask one of the trunk genres for its tracks it finds all the tracks associated directly with the trunk or with any of the genre’s sub genres. It’s made doubly complicated by the fact that the genre is related to its tracks through a relationship model, and triply complicated that we’re going to want to be able to be able to search within the basic set of results (because, usually, we don’t want 300 tracks on a page…)

The solution I ended up with runs to about two emacs screenfuls and it’s ugly as hell. We’re having to declare custom ‘select_sql’ for getting the basic collection, and then extending the association with a custom ‘find’ and method_missing, and you can forget about making genre.tracks.create work because life is far too short.

There’s no doubting that the solution is clever; it took a couple of hours of concentrated thought and experimentation to come up with it. However, it’s definitely Bad Clever.