Class: ApplicationController

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

Overview

This controller contain the methods shared for all controller

Instance Method Summary collapse

Instance Method Details

#access_denied!nil (private)

Render 401 page and stop the work

Returns:

  • (nil)


31
32
33
# File 'app/controllers/application_controller.rb', line 31

def access_denied!
  render "errors/401", status: :unauthorized and return
end

#default_url_optionsObject



8
9
10
# File 'app/controllers/application_controller.rb', line 8

def default_url_options
  { locale: I18n.locale }
end

#record_not_found!nil (private)

Render 404 page and stop the work

Returns:

  • (nil)


25
26
27
# File 'app/controllers/application_controller.rb', line 25

def record_not_found!
  render partial: "errors/404", status: :not_found and return
end

#set_turboObject (private)



35
36
37
# File 'app/controllers/application_controller.rb', line 35

def set_turbo
  @turbo = request.headers["turbo-frame"].present?
end

#switch_locale(&action) ⇒ Object (private)



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

def switch_locale(&action)
  locale = params[:locale] || I18n.default_locale
  I18n.with_locale(locale, &action)
end