Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # base.rb
- module API
- class Base < Grape::API
- include API::Base::Defaults
- mount API::V1::Base
- end
- end
- # defaults.rb
- module API
- module Defaults
- extend ActiveSupport::Concern
- included do
- prefix 'api'
- default_format :json
- format :json
- helpers do
- def permitted_params
- @permitted_params ||= declared(params,
- include_missing: false)
- end
- def logger
- Rails.logger
- end
- end
- rescue_from ActiveRecord::RecordNotFound do |e|
- error_response(message: e.message, status: 404)
- end
- rescue_from ActiveRecord::RecordInvalid do |e|
- error_response(message: e.message, status: 422)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement