I have a Rails 3.2.6 application which requires you to login to use it. It also has an Rails Engine mounted to /api
which provides a JSON API to certain parts, without requiring authentication.
When I kick up the Rails server and make the following requests:
GET /api/something
GET /
GET /api/something
Everything works as expected, the API requests returns JSON as they should, the home page renders the html page.
Here's the weird part. If I make the requests in this order right after starting the Rails server:
GET /
GET /api/something
GET /api/something
Then the API requests fail. The before filters from the root Rails app fire for the API engine, causing a redirect to UserSessionsController#new
, which doesn't exist in the API engine, and fails. While if make a request to the API engine first instead of the root Rails app, the API engine does not inherit before filters. Any light shed on this weirdness would be great :)
Though my current plan is to turn the API engine into a properly self-contained Rack app. It seems the only reason it's an engine at this point is cause someone before me really liked engines.