Class: Tramway::Api::V1::ApplicationController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tramway/api/v1/application_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate, #not_found, #unauthorized

Instance Method Details

#render_error_with_text(text) ⇒ Object



11
12
13
# File 'app/controllers/tramway/api/v1/application_controller.rb', line 11

def render_error_with_text(text)
  render json: { text: text }, status: :bad_request
end

#render_errors_for(model) ⇒ Object



7
8
9
# File 'app/controllers/tramway/api/v1/application_controller.rb', line 7

def render_errors_for(model)
  render json: model, status: :unprocessable_entity, serializer: ::Tramway::Api::V1::ErrorSerializer
end

#snake_case(params) ⇒ Object



15
16
17
18
19
20
21
22
# File 'app/controllers/tramway/api/v1/application_controller.rb', line 15

def snake_case(params)
  hash = {}
  params.each do |attribute, value|
    key = ::UUID.validate(attribute) ? attribute : attribute.to_s.gsub('-', '_')
    hash.merge! key => value
  end
  hash
end