Files
astuto/app/controllers/application_controller.rb

28 lines
755 B
Ruby
Raw Normal View History

2019-08-18 14:51:37 +02:00
class ApplicationController < ActionController::Base
2022-06-10 12:03:33 +02:00
include Pundit::Authorization
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
2019-08-19 15:45:44 +02:00
before_action :configure_permitted_parameters, if: :devise_controller?
2019-08-22 17:09:13 +02:00
before_action :load_boards
2019-08-19 15:45:44 +02:00
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:full_name, :notifications_enabled])
devise_parameter_sanitizer.permit(:account_update, keys: [:full_name, :notifications_enabled])
2019-08-19 15:45:44 +02:00
end
2019-08-22 17:09:13 +02:00
def load_boards
@boards = Board.select(:id, :name).order(order: :asc)
2019-08-22 17:09:13 +02:00
end
2022-06-10 12:03:33 +02:00
private
def user_not_authorized
render json: {
error: t('backend.errors.unauthorized')
}, status: :unauthorized
end
2019-08-18 14:51:37 +02:00
end