Cleanup permalink generation

Fix permalink generation to not contain various smells. See verbose description in the last commit in this PR.
AR does not implement `respond_to_missing?` for dynamic finders so this trick does not work.