Class: Tracebook::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Tracebook::ApplicationController
- Defined in:
- app/controllers/tracebook/application_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#current_tracebook_user_label ⇒ String
protected
Returns a display name for the current user from the host app.
- #render_not_found ⇒ Object protected
Instance Method Details
#current_tracebook_user_label ⇒ String (protected)
Returns a display name for the current user from the host app. Tries common patterns: email, name, id. Falls back to "Anonymous".
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/tracebook/application_controller.rb', line 15 def current_tracebook_user_label return "Anonymous" unless respond_to?(:current_user, true) && current_user if current_user.respond_to?(:email) && current_user.email.present? current_user.email elsif current_user.respond_to?(:name) && current_user.name.present? current_user.name elsif current_user.respond_to?(:id) "User ##{current_user.id}" else "Anonymous" end end |
#render_not_found ⇒ Object (protected)
7 8 9 |
# File 'app/controllers/tracebook/application_controller.rb', line 7 def render_not_found render plain: "Not Found", status: :not_found end |