title: Override Redmine core methode
body: <p>I want to override a method from Redmine Core using a Patch in a plugin but I'm not able to make it working :-(.</p>
  
  <p>I want to change the behavior of the method <strong>try_to_login</strong> from the Redmine core.</p>
  
  <p>Here is my Init.rb:</p>
  
  <pre><code>require 'redmine'
  require 'user_patch'
  
  ActionDispatch::Callbacks.to_prepare do
    require_dependency 'project'
    require_dependency 'principal'
    require_dependency 'user'
    unless User.included_modules.include? UserPatch
      User.send :include, UserPatch
    end
  end
  
  Redmine::Plugin.register :security do
    name 'Security plugin'
    author 'Author name'
    description 'This is a plugin for Redmine'
    version '0.0.1'
    url 'http://example.com/path/to/plugin'
    author_url 'http://example.com/about'
  
  end
  </code></pre>
  
  <p>and my patch file:</p>
  
  <pre><code>module UserPatch
  
      def self.included(base)
      base.send(:include, InstanceMethods)
          base.class_eval do
              alias_method :try_to_login, :try_to_login_with_patch        
          end
      end 
  
      module InstanceMethods
        # Returns the user that matches provided login and password, or nil
        def try_to_login_with_patch(login, password, active_only=true)
              &lt;do somthing ...&gt;
        end
  
  
      end
  end
  </code></pre>
  
  <p>Any idea what is wrong in this ?</p>
  
  <p>Thanks you in avance.</p>
  
  <p>Regards,</p>
  
  <p>Aniss</p>