title: No Route Matches ... Rails Engine
body: <p>So I keep getting the error:</p>
  
  <p><code>No route matches {:action=&gt;"create", :controller=&gt;"xaaron/api_keys"}</code></p>
  
  <p>Which is thrown in the test:</p>
  
  <pre><code>it "should not create an api key for those not logged in" do
    post :create
    expect(response).to redirect_to xaaron.login_path
  end
  </code></pre>
  
  <p>when I go to <code>spec/dummy</code> and run the <code>rake routes</code> command I see:</p>
  
  <pre><code>       api_keys GET    /api_keys(.:format)                 xaaron/api_keys#index
                  POST   /api_keys(.:format)                 xaaron/api_keys#create
      new_api_key GET    /api_keys/new(.:format)             xaaron/api_keys#new
     edit_api_key GET    /api_keys/:id/edit(.:format)        xaaron/api_keys#edit
          api_key GET    /api_keys/:id(.:format)             xaaron/api_keys#show
                  PATCH  /api_keys/:id(.:format)             xaaron/api_keys#update
                  PUT    /api_keys/:id(.:format)             xaaron/api_keys#update
                  DELETE /api_keys/:id(.:format)             xaaron/api_keys#destroy
  </code></pre>
  
  <p>Which shows that yes this route does exist. My routes file for this engine looks like:</p>
  
  <pre><code>Xaaron::Engine.routes.draw do
        get 'login' =&gt; 'sessions#new', :as =&gt; 'login'
        get 'logout' =&gt; 'sessions#destroy', :as =&gt; 'logout'
        get 'signup' =&gt; 'users#new', :as =&gt; 'signup'
        get 'permission_denied' =&gt; 'error#denied', :as =&gt; 'permission_denied'
        get 'record_not_found' =&gt; 'error#error', :as =&gt; 'record_not_found'
        get 'password_reset' =&gt; 'password_resets#edit', :as =&gt; 'rest_user_password'
  
        resource :error, controller: 'error'
  
        resources :users
        resources :api_keys
        resources :sessions
        resources :roles
        resources :password_resets
  end
  </code></pre>
  
  <p>What am I missing?</p>
  
  <h1>update</h1>
  
  <p>For those of you curious how I am getting these routes, its because the dummy app's routes file is set up (by default) as such:</p>
  
  <pre><code>Rails.application.routes.draw do
  
    mount Xaaron::Engine =&gt; "/xaaron"
  end
  </code></pre>
  
  <h1>Update II</h1>
  
  <p>I have been reading <a href="http://api.rubyonrails.org/classes/Rails/Engine.html">this api docs on how routing is done in engines</a> and I believe the way I have done this is correct, how ever the controller is defined as such:</p>
  
  <pre><code>module Xaaron
    class ApiKeysController &lt; ActionController::Base
      before_action :authenticate_user!
  
      def index
        @api_key = Xaaron::ApiKey.where(:user_id =&gt; current_user.id)
      end
  
      def create
        @api_key = Xaaron::ApiKey.new(:user_id =&gt; current_user.id, :api_key =&gt; SecureRandom.hex(16))
        create_api_key(@api_key)
      end
  
      def destroy
        Xaaron::ApiKey.find(params[:id]).destroy
        flash[:notice] = 'Api Key has been deleted.'
        redirect_to xarron.api_keys_path
      end
    end
  end
  </code></pre>