Reputation: 320
I want to assign different routes depending on the internal setting. A simple if
won't work here as routes.rb
is only evaluated on change/start. I want to redirect all requests to a maintenance page if the maintenance is in progress without changing the current URL.
Upvotes: 0
Views: 1192
Reputation: 898
You could have a before filter in the ApplicationController that renders a maintenance template. It should look something like this:
class ApplicationController < ActionController::Base
before_filter :show_maintenance_page
private
def show_maintenance_page
render 'common/maintenance' if maintenance? # you have to define maintenance?
end
end
Upvotes: 2
Reputation: 13344
You could set an action in the ApplicationController as a before_filter
to check an environment variable and, if that is set, render
a maintenance template. This shouldn't affect the current URL.
Upvotes: 3