summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
blob: 41efab041bd17de690bbec14fd7f8cfe6cec6d9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class ApplicationController < ActionController::Base
  include Authenticatable
  include Featurable
  protect_from_forgery with: :exception
  around_action :apply_locale
  add_flash_types :error, :warning

  def render_error(status, model: nil)
    @model = model
    render template: "errors/#{status}", status: status
  end

  def apply_locale
    I18n.with_locale(current_user&.locale || I18n.default_locale) do
      yield
    end
  end
end