2019-09-04 21:01:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module UsersHelpers
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
extend Grape::API::Helpers
|
|
|
|
|
|
|
|
params :optional_params_ee do
|
|
|
|
end
|
|
|
|
|
|
|
|
params :optional_index_params_ee do
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
def model_error_messages(model)
|
|
|
|
super.tap do |error_messages|
|
|
|
|
# Remapping errors from nested associations.
|
|
|
|
error_messages[:bio] = error_messages.delete(:"user_detail.bio") if error_messages.has_key?(:"user_detail.bio")
|
|
|
|
end
|
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
def find_user_by_id(params)
|
|
|
|
id = params[:user_id] || params[:id]
|
|
|
|
User.find_by(id: id) || not_found!('User')
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2019-09-04 21:01:54 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
API::Helpers::UsersHelpers.prepend_mod_with('API::Helpers::UsersHelpers')
|