Skip to content

Setting up Routing Constraints

Tim Fischbach edited this page Jul 18, 2014 · 6 revisions

This documentation refers to features which are available in Pageflow verion 0.2.0 and above.

When there are different CNAMES pointing to your Pageflow installation, you can restrict access to the admin interface to a single host name. That way entries can be published under different URLs while the admin interface is only available under the official domain.

Define a routing constraint:

class HostConstraint
  def matches?(request)
    request.host == 'pageflow.example.com'
  end
end

For the active admin routes, you have to apply the constraint manually in your config/routes.rb:

PageflowExample::Application.routes.draw do
  constraints HostConstraint.new do
    devise_for :users, ActiveAdmin::Devise.config
    ActiveAdmin.routes(self)

    root :to => redirect('/admin')
  end

  Pageflow.routes(self)
end

Finally, in the Pageflow initializer, activate the constraint for the editor routes defined by Pageflow:

  config.editor_route_constraint = HostConstraint.new
Clone this wiki locally