mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
Improve rails controllers (#118)
This commit is contained in:
committed by
GitHub
parent
8e75a85873
commit
94f77517a8
@@ -1,4 +1,8 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include Pundit::Authorization
|
||||
|
||||
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
||||
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
before_action :load_boards
|
||||
|
||||
@@ -12,4 +16,12 @@ class ApplicationController < ActionController::Base
|
||||
def load_boards
|
||||
@boards = Board.select(:id, :name).order(order: :asc)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_not_authorized
|
||||
render json: {
|
||||
error: t('backend.errors.unauthorized')
|
||||
}, status: :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user