-
Notifications
You must be signed in to change notification settings - Fork 129
Setting up Routing Constraints
Tim Fischbach edited this page Jul 4, 2014
·
6 revisions
This documentation refers to features which will be part of the next gem release and are currently only available on the master branch.
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