Class: Commentui::ApplicationController

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

Direct Known Subclasses

CommentsController

Instance Method Summary collapse

Instance Method Details

#check_commentui_userObject



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

def check_commentui_user
  return if commentui_user.present?

  render_json_errors("Permission denied")
end

#commentui_userObject



23
24
25
# File 'app/controllers/commentui/application_controller.rb', line 23

def commentui_user
  @commentui_user ||= Commentui.current_user_lambda.call(self)
end

#record_not_foundObject



13
14
15
# File 'app/controllers/commentui/application_controller.rb', line 13

def record_not_found
  render_json_errors("Record not found", :not_found)
end

#render_json_errors(errors, status = :unprocessable_entity) ⇒ Object



6
7
8
9
10
11
# File 'app/controllers/commentui/application_controller.rb', line 6

def render_json_errors(errors, status=:unprocessable_entity)
  errors = [errors] unless errors.instance_of?(Array)
  render json: {
    errors: errors
  }, status: status
end