Module: Sufia::Controller
- Extended by:
- ActiveSupport::Concern
- Included in:
- GenericFilesController
- Defined in:
- app/controllers/concerns/sufia/controller.rb
Instance Method Summary collapse
-
#after_sign_in_path_for(resource) ⇒ Object
Override Devise method to redirect to dashboard after signing in.
- #current_ability ⇒ Object
- #normalize_identifier ⇒ Object
- #notifications_number ⇒ Object
- #render_404(exception) ⇒ Object
- #render_500(exception) ⇒ Object
- #render_single_use_error(exception) ⇒ Object
Instance Method Details
#after_sign_in_path_for(resource) ⇒ Object
Override Devise method to redirect to dashboard after signing in
45 46 47 |
# File 'app/controllers/concerns/sufia/controller.rb', line 45 def after_sign_in_path_for(resource) sufia.dashboard_index_path end |
#current_ability ⇒ Object
11 12 13 |
# File 'app/controllers/concerns/sufia/controller.rb', line 11 def current_ability user_signed_in? ? current_user.ability : super end |
#normalize_identifier ⇒ Object
15 16 17 |
# File 'app/controllers/concerns/sufia/controller.rb', line 15 def normalize_identifier params[:id] = Sufia::Noid.namespaceize(params[:id]) end |
#notifications_number ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/concerns/sufia/controller.rb', line 34 def notifications_number @notify_number = 0 @batches = [] return if action_name == "index" && controller_name == "mailbox" if user_signed_in? @notify_number = current_user.mailbox.inbox(unread: true).count @batches = current_user.mailbox.inbox.map { |msg| msg..body[/<span id="(.*)"><a (href=|data-content=)(.*)/,1] }.select{ |val| !val.blank? } end end |
#render_404(exception) ⇒ Object
19 20 21 22 |
# File 'app/controllers/concerns/sufia/controller.rb', line 19 def render_404(exception) logger.error("Rendering 404 page due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}") render template: '/error/404', layout: "error", formats: [:html], status: 404 end |
#render_500(exception) ⇒ Object
24 25 26 27 |
# File 'app/controllers/concerns/sufia/controller.rb', line 24 def render_500(exception) logger.error("Rendering 500 page due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}") render template: '/error/500', layout: "error", formats: [:html], status: 500 end |
#render_single_use_error(exception) ⇒ Object
29 30 31 32 |
# File 'app/controllers/concerns/sufia/controller.rb', line 29 def render_single_use_error(exception) logger.error("Rendering PAGE due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}") render template: '/error/single_use_error', layout: "error", formats: [:html], status: 404 end |