How can I combine Rails' params.require
with apiepie's param_group
to avoid duplication?
Asked
Active
Viewed 486 times
2

quantumpotato
- 9,637
- 14
- 70
- 146
1 Answers
0
I know that it's a little bit late to reply, but here's how to do it:
- Create a controller that extends ApiPie:
class ApiController < ActionController::Base extend Apipie::DSL::Concern
- Define
param_groups
in that controller:
def_param_group :param_errors do
error code: 200, desc: "Success"
error code: 400, desc: "Error"
error code: 401, desc: "Unauthorized"
error code: 404, desc: "Not Found"
end
- Extend this controller from your second controller:
class MyCustomController < ApiController
- Call the
param_group
before your function using:
param_group :param_errors, ApiController
def my_method
# ...
end

zhirzh
- 3,273
- 3
- 25
- 30

Roc Khalil
- 1,365
- 6
- 22