Class: Hicube::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/hicube/application_controller.rb

Direct Known Subclasses

BaseController, Public::BaseController

Constant Summary collapse

FLASH_TYPES =

Constants

[
  :debug,
  :error,
  :notice,
  :alert,
  :success,
  :warning,
]

Instance Method Summary collapse

Instance Method Details

#after_sign_in_path_for(resource) ⇒ Object



41
42
43
# File 'app/controllers/hicube/application_controller.rb', line 41

def (resource)
  return request.env['omniauth.origin'] || stored_location_for(resource) || '/hicube/pages/index/edit'
end

#notify(type, message, options = {}) ⇒ Object

Generate a notification message.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/hicube/application_controller.rb', line 46

def notify(type, message, options = {})
  options[:now] ||= false

  # Convert and cleanup.
  type = type.to_s.downcase.to_sym

  # Sanity check for type.
  unless FLASH_TYPES.include?(type)
    raise ArgumentError, "Invalid value for argument type: #{type}, expected one of: #{FLASH_TYPES.to_sentence}."
  end

  logger.info("FLASH (#{options.inspect}) #{type.to_s.upcase}: #{message}")

  if options[:now] == true
    flash.now[type] ||= []
    flash.now[type] << message
  else
    flash[type] ||= []
    flash[type] << message
  end

  logger.debug("DEBUG: FLASH #{flash.inspect}")

  return true
end

#notify_now(type, message, options = {}) ⇒ Object



72
73
74
75
# File 'app/controllers/hicube/application_controller.rb', line 72

def notify_now(type, message, options = {})
  options[:now] = true
  notify(type, message, options)
end