Class: ApplicationController

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

Overview

This conroller contain the methods shared for all sons

  • layout :set_layout -> set the view layout with #set_layout method

  • before_action :authenticate_user! -> before every action execute devise.authenticate_user! method. This method check if the user is signed in or require authentication

  • before_action :set_locale

Raises:

  • (ActiveRecord::RecordNotFound)

    if a query can’t be resolved execute #record_not_found!

Instance Method Summary collapse

Instance Method Details

#admin_in!nil

Execute #access_denied unless current_user.admin == true

Returns:

  • (nil)


46
47
48
# File 'app/controllers/application_controller.rb', line 46

def admin_in!
  access_denied! unless current_user.admin?
end

#doctor_in!nil

Execute #access_denied! unless current_user.doctor == TRUE

Returns:

  • (nil)


33
34
35
# File 'app/controllers/application_controller.rb', line 33

def doctor_in!
  access_denied! unless current_user.doctor?
end

#powered_in!nil

Execute #access_denied! unless current_user.doctor == true or current_user.secretary == true

Returns:

  • (nil)


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

def powered_in!
  access_denied! unless current_user.doctor? || current_user.secretary?
end

#secretary_in!nil

Execute #access_denied! unless current_user.secretary == TRUE

Returns:

  • (nil)


27
28
29
# File 'app/controllers/application_controller.rb', line 27

def secretary_in!
  access_denied! unless current_user.secretary?
end

#translate_errors(errors = [], scope: '') ⇒ Object



50
51
52
53
54
55
56
# File 'app/controllers/application_controller.rb', line 50

def translate_errors(errors = [], scope: '')
  translated = []
  errors.each do |e|
    translated << "#{t(e.attribute, scope: scope, default: e.attribute)} #{e.message}"
  end
  return translated
end