Q:

Overwriting methods in a module

I am using a gem in my rails app, and there is a method that I would like to override.  The gam is authlogic, and the specific method I was to override is find_by_smart_case_login_field(login). 
I made a file in lib/modules with the following code: 
# lib/modules/login.rb
module Authlogic
  module ActsAsAuthentic
    module Login
      module Config
        def find_by_smart_case_login_field(login)
          login = login.downcase unless validates_uniqueness_of_login_field_options[:case_sensitive] 

          if login_field
            where({ login_field.to_sym => login })
          else
            where({ email_field.to_sym => login })
          end
        end
      end
    end
  end
end

But this didn't do anything.  Does anyone know how to overwrite the above method? 

A:

Well, you are monkey patching a gem.  Not bad, just don't abuse it:)
Two things you need to do before making your monkey patching works. 

Add /lib to auto load path otherwise Rails don't know it. 
In config/application.rb, find the autoload_path line, change it to
config.autoload_paths += %W(#{config.root}/extras #{config.root}/lib)

Require your custom module at app loading. 
In config/initializers, add a custom file say application.rb, then add the following line
require 'modules/login.rb'
# Pay attention: No "lib/" before the file path

Now, profit! 
As to module path, it doesn't matter as long as your module nesting is correct in the file.