Add support for Rails 4

I understand that the `ApplicationRouter` is quite kludgy, but for now this should suffice.