Class: ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ApplicationController
- Defined in:
- app/controllers/application_controller.rb
Direct Known Subclasses
ActivitiesController, AttachmentsController, BookmarksController, CorporationsController, ErrorsController, EventsController, GroupsController, OfficersController, PagesController, PostsController, ProfileFieldsController, RootController, SearchController, SetupController, StatisticsController, StatusGroupMembershipsController, TermsOfUseController, UserAccountsController, UserGroupMembershipsController, UserSettingsController, UsersController
Instance Method Summary collapse
-
#current_navable ⇒ Object
This method returns the navable object the navigational elements on the currently shown page point to.
-
#current_navable=(navable) ⇒ Object
This method sets the currently shown navable object.
-
#current_user ⇒ Object
This method returns the currently signed in user.
- #point_navigation_to(navable) ⇒ Object
-
#redirect_www_subdomain ⇒ Object
Redirect the www subdomain to non-www, e.g.
-
#set_locale ⇒ Object
The locale of the application s set as follows: 1.
Instance Method Details
#current_navable ⇒ Object
This method returns the navable object the navigational elements on the currently shown page point to.
For example, if the bread crumb navigation reads ‘Start > Intranet > News’, the current_navable would return the with ‘News’ associated navable object.
This also means, that the current_navable has to be set in the controller through point_navigation_to.
43 44 45 |
# File 'app/controllers/application_controller.rb', line 43 def current_navable @navable end |
#current_navable=(navable) ⇒ Object
This method sets the currently shown navable object. Have a look at #current_navable.
50 51 52 |
# File 'app/controllers/application_controller.rb', line 50 def current_navable=( navable ) @navable = navable end |
#current_user ⇒ Object
This method returns the currently signed in user.
30 31 32 |
# File 'app/controllers/application_controller.rb', line 30 def current_user current_user_account.user if current_user_account end |
#point_navigation_to(navable) ⇒ Object
53 54 55 |
# File 'app/controllers/application_controller.rb', line 53 def ( navable ) self.current_navable = navable end |
#redirect_www_subdomain ⇒ Object
Redirect the www subdomain to non-www, e.g. www.example.com to example.com.
60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/application_controller.rb', line 60 def redirect_www_subdomain if (request.host.split('.')[0] == 'www') and (not Rails.env.test?) # A flash cross-domain flash message would only work if the cookies are shared between the subdomains. # But we won't make this decision for the main app, since this can be a security risk on shared domains. # More info on sharing the cookie: http://stackoverflow.com/questions/12359522/ # flash[:notice] = I18n.t(:you_may_leave_out_www) redirect_to "http://" + request.host.gsub('www.','') end end |
#set_locale ⇒ Object
The locale of the application s set as follows:
1. Use the url parameter 'locale' if given.
2. Use the language of the web browser if supported by the app.
3. Use the default locale if no other could be determined.
76 77 78 79 80 81 |
# File 'app/controllers/application_controller.rb', line 76 def set_locale [:locale] = secure_locale_param if params[:locale].present? [:locale] = nil if params[:locale] and params[:locale] == "" [:locale] = nil if [:locale] == "" I18n.locale = [:locale] || browser_language_if_supported_by_app || I18n.default_locale end |