gblakeman/lockup — pull request #6 by mackermedia (2013-12-11 20:02:17+00:00)
Title: Removes auto-mounting of engine after main application's routes.

I was experiencing an infinite redirect loop, and discovered the cause was due to specifying a catch all route in my main application's route file.

Example:
```
# need this because Rails `rescue_from` doesn't catch ActionController::RoutingError
unless Rails.env.development?
match '*path', :via => :all, :to => 'application#render_404'
end
```

The cause of this was because lockup has a `before_filter` specified for all routes other than its own `/lockup` path.

It looks like in Rails 3 you can specify routes multiple times just fine without it blowing up, so recommending to manually add the mounting of the engine in the routes file will work.

```
lockup /lockup Lockup::Engine
ALL /*path(.:format) application#render_404
lockup /lockup Lockup::Engine
```

However, Rails 4 does not allow defining a path multiple times. It will fail with:
```
actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:434:in `add_route': Invalid route name, already in use: 'lockup' (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
```

I thought about trying to dynamically define the lockup routes at the top of the main application's routes file, but the solution felt like a hack as seen in this SO answer: http://stackoverflow.com/questions/6915316/controlling-routes-loading-order-from-engines

I'm proposing having to manually mount the engine where you'd like in your routes file in all cases. This is a common pattern for mounting engines.