Search code examples
ruby-on-rails-4rails-enginesrack-pow

Pow doesn't recognize engine-created routes


I've got a Rails engine (for authentication, though I don't think it will matter). It comes, as is traditional, with a dummy app in the /spec directory. The engine defines a couple of routes in the application, and the dummy app defines a few of its own.

When I run the dummy app in WEBrick using rails s, it works fine. However, when try to run it using Pow (symlinking to my_engine/spec/dummy in ~/.pow), it doesn't seem to recognize the routes provided by the engine, and I get:

ActionController::UrlGenerationError at /login
No route matches {:action=>"new", :controller=>"my_engine/sessions"}

What's wrong with this, and why does it only happen in Pow?

Here are the routes files, in case it matters:

my_engine/config/routes.rb:

Rails.application.routes.draw do

  get 'login', :controller => 'my_engine/sessions', :action => :new
  post 'login', :controller => 'my_engine/sessions', :action => :create
  get 'logout', :controller => 'my_engine/sessions', :action => :destroy

end

my_engine/spec/dummy/config/routes.rb:

Rails.application.routes.draw do

  mount MyEngine::Engine => "/auth"

  root 'home#index'

  controller :home do
    get :index
    get :private, :as => 'private'
  end

end

Edit: I've determined that this doesn't work when the engine is used in a normal application as well, so it's not just the dummy app.


Solution

  • So, turned out to be completely unrelated. The engine-served page I was linking to contained a link_to helper in which the second argument (the path) was dependent on ENV['RAILS_ENV']. In Pow, this value was nil (whereas in WEBrick, it was set to 'development', as the author presumably expected), and so it was trying to render link_to('text', nil). Which somehow produced the above error.