< mockra >

Doorkeeper Views - 20 Jun 2012

Doorkeeper is a great tool for quickly creating an OAuth based API. Information on setting up Doorkeeper can be found on the Github page here.

Once you setup Doorkeeper, you’re more than likely going to want to customize the layout of the application. If you want full control over the views, run rails generate doorkeeper:views. Most of the time, the default views will work for your application and you’ll simply want to change the layout.

Changing the Doorkeeper layout can be done in config/application.rb. Here’s how you can change the layout for all of your Doorkeeper views.

config.to_prepare do

  Doorkeeper::ApplicationController.layout "name_of_your_layout"


You’ll then need to create the new layout that Doorkeeper will use. To access your applications named routes, you’ll need to preface them with main_app, here’s an example: main_app.new_user_path.

When accessing Doorkeeper’s routes, such as applications_path and authorized_applications_path in the Doorkeeper layout, you won’t need to preface those routes.

If you’re using Doorkeeper routes in your own application’s views, then you will need to preface them with doorkeeper. Here’s an example: doorkeeper.applications_path