Class: ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ApplicationController
- Defined in:
- app/controllers/application_controller.rb
Overview
The main application controller for RLetters
This controller implements functionality shared throughout the entire RLetters site.
Direct Known Subclasses
DatasetsController, ErrorsController, InfoController, LibrariesController, SearchController, UnapiController
Instance Method Summary (collapse)
-
- (undefined) ensure_trailing_slash
private
private
Make sure there's a trailing slash on the URL.
-
- (undefined) set_locale
private
private
Set the locale if the user is logged in.
-
- (undefined) set_timezone
private
private
Set the timezone if the user is logged in.
-
- (Boolean) trailing_slash?
private
private
Does the URL end with a trailing slash?.
Instance Method Details
- (undefined) ensure_trailing_slash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Make sure there's a trailing slash on the URL
jQuery Mobile really wants us always to have a trailing slash on our URLs, since we often are redirecting to subdirectory pages (e.g., from /datasets/ to /datasets/2/ to /datasets/2/task/3/results/, etc.). This helper makes sure we've always got a trailing slash. Don't disable it!
55 56 57 |
# File 'app/controllers/application_controller.rb', line 55 def ensure_trailing_slash redirect_to url_for(params.merge(:trailing_slash => true)), :status => 301 unless trailing_slash? end |
- (undefined) set_locale (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the locale if the user is logged in
This function is called as a before_filter in all controllers, you do not need to call it yourself. Do not disable it, or the locale system will go haywire.
22 23 24 25 26 27 28 |
# File 'app/controllers/application_controller.rb', line 22 def set_locale if user_signed_in? I18n.locale = current_user.language.to_sym else I18n.locale = I18n.default_locale end end |
- (undefined) set_timezone (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the timezone if the user is logged in
This function is called as a before_filter in all controllers, you do not need to call it yourself. Do not disable it, or the timezone system will go haywire.
38 39 40 41 42 43 44 |
# File 'app/controllers/application_controller.rb', line 38 def set_timezone if user_signed_in? Time.zone = current_user.timezone else Time.zone = 'Eastern Time (US & Canada)' end end |
- (Boolean) trailing_slash? (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Does the URL end with a trailing slash?
62 63 64 65 66 67 68 |
# File 'app/controllers/application_controller.rb', line 62 def trailing_slash? # If fullpath isn't defined (e.g., in testing), then just return true # so we don't do unnecessary redirects. return true if request.env['REQUEST_URI'].blank? request.env['REQUEST_URI'].match(/[^\?]+/).to_s.last == '/' end |