title: Why do these modules have to be included in the correct order for CanCanCan to work?
body: <p>I have the following code for being able to render an XML document without it being part of a request:</p>
  
  <pre><code>class ExportMetadataService
    # Inheriting avoids NoMethodError: undefined method `abstract?' for Object:Class
    class ItemOfflineTemplate &lt; AbstractController::Base
      # Used for render_to_string
      include AbstractController::Rendering
      # Both of the following lines are required for cancan, and have to be in the correct order.
      include AbstractController::Helpers
      include CanCan::ControllerAdditions
  
      attr_accessor :item
  
      def initialize
        # No evidence of being required, but probably good practice.
        super()
        # Avoids ActionView::MissingTemplate
        lookup_context.view_paths = Rails.root.join('app', 'views')
      end
  
      # CanCan requires a current_user
      def current_user
        @current_user ||= User.admins.first
      end
    end
  end
  </code></pre>
  
  <p>The code for rendering the XML is the following:</p>
  
  <pre><code>item = Item.first
  template = ExportMetadataService::ItemOfflineTemplate.new
  template.item = item
  template.render_to_string :template =&gt; "items/show.imp.xml"
  </code></pre>
  
  <p>and the template starts with</p>
  
  <pre><code>-if can? :manage, @item
  </code></pre>
  
  <p>If I run the code as shown above, it works fine. However, if I change the order of the controllers, such that <code>include CanCan::ControllerAdditions</code> happens before <code>include AbstractController::Helpers</code>, it gives the following error:</p>
  
  <pre><code>ActionView::Template::Error: undefined method `can?' for #&lt;#&lt;Class:0x007fa2871821e0&gt;:0x007fa28718bab0&gt;
  from /Users/agrimm/rails/nabu/app/views/items/show.imp.xml.haml:1:in `_app_views_items_show_imp_xml_haml__3049376767338038218_70168013983060'
  </code></pre>
  
  <p>It can't be that <code>CanCan::ControllerAdditions</code> overrides a method in <code>AbstractController::Helpers</code>, because it's a NoMethodError, rather than <code>AbstractController::Helpers</code> providing an implementation that isn't desired.</p>
  
  <p>I'm using Rails 3.2, and CanCanCan 1.13.1.</p>