title: Adding to ActiveRecord::ConnectionAdapters::MysqlAdapter
body: <p>For general knowledge and entertainment purposes I am trying to add some behavoiur to Rails. What I am looking for is simply to run a Mysql "EXPLAIN" statement before every select statement that Rails runs. I think this should work ok but I am getting the error:</p>
  
  <p>/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/module/aliasing.rb:32:in <code>alias_method': undefined method</code>select_with_explain' for class `ActiveRecord::ConnectionAdapters::MysqlAdapter' (NameError)</p>
  
  <p>This class is located in the initializers dir. Here is the code:</p>
  
  <pre><code>    module Explanifier
  
        def self.included(base)
  
          base.class_eval do
            extend ClassMethods
            alias_method_chain :select, :explain
  
  
          end
        end
        module ClassMethods
          def select_with_explain(sql, name = nil)
            puts "testing!!!"
            execute('EXPLAIN ' + sql, name)
            select_without_explain(sql, name)
          end
        end
  
      end
  
  
  
      class ActiveRecord::ConnectionAdapters::MysqlAdapter
        include Explanifier
      end
  </code></pre>
  
  <p>Can someone explain what I am missing here?</p>