Class: ApplicationController

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

Constant Summary collapse

APP_DOMAIN =

pretty sure this isnt used and can be removed

'hospitium.co'

Instance Method Summary collapse

Instance Method Details

#after_sign_in_path_for(resource_or_scope) ⇒ Object

redirect to /admin after all logins


19
20
21
# File 'app/controllers/application_controller.rb', line 19

def (resource_or_scope)
  '/admin'
end

#canonical_url(canonical_url) ⇒ Object


60
61
62
# File 'app/controllers/application_controller.rb', line 60

def canonical_url(canonical_url)
  @canonical_url = canonical_url
end

#check_domainObject


54
55
56
57
58
# File 'app/controllers/application_controller.rb', line 54

def check_domain
  if Rails.env.production? and request.host.downcase != 'hospitium.co'
    redirect_to request.protocol + 'hospitium.co' + request.fullpath, status: 301
  end
end

#ensure_domainObject


42
43
44
45
46
47
# File 'app/controllers/application_controller.rb', line 42

def ensure_domain
  if request.env['HTTP_HOST'] != APP_DOMAIN
    # HTTP 301 is a "permanent" redirect
    redirect_to "https://#{APP_DOMAIN}", status: 301
  end
end

#get_noticeObject

display notice on every admin page


12
13
14
15
16
# File 'app/controllers/application_controller.rb', line 12

def get_notice
  @random_notice = Rails.cache.fetch('random_notifications', expires_in: 1.minutes) do
    Notification.offset(rand(Notification.count)).select('notifications.message, notifications.status_type').first() unless Notification.count == 0
  end
end