Module: JsApplicationReloader::ControllerExtensions
- Defined in:
- lib/js_application_reloader/controller_extensions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #handle_js_application_reloader_token_expiration ⇒ Object
-
#render_js_application_reloader_expiration ⇒ Object
override me in your ApplicationController to customize what gets sent back to the client on token expiration.
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/js_application_reloader/controller_extensions.rb', line 4 def self.included(base) base.before_filter :handle_js_application_reloader_token_expiration end |
Instance Method Details
#handle_js_application_reloader_token_expiration ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/js_application_reloader/controller_extensions.rb', line 8 def handle_js_application_reloader_token_expiration # Note: we do a string comparision to avoid 232323 not matching "232323" mistakes if request.headers[JsApplicationReloader.token_header_name] && (request.headers[JsApplicationReloader.token_header_name].to_s != JsApplicationReloader.token.to_s) response.headers[JsApplicationReloader.status_header_name] = 'token_expired' render_js_application_reloader_expiration end end |
#render_js_application_reloader_expiration ⇒ Object
override me in your ApplicationController to customize what gets sent back to the client on token expiration
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/js_application_reloader/controller_extensions.rb', line 18 def render_js_application_reloader_expiration = "A new version of #{JsApplicationReloader.application_name} is available. " + "Please click <a href='#{JsApplicationReloader.redirect_url}'>here</a> to load it." respond_to do |format| format.html { render :text => , :status => JsApplicationReloader.reload_required_http_status } format.json { render :json => {:message => }, :status => JsApplicationReloader.reload_required_http_status } end end |