I'm trying to automate some documentation for an API and would like to retrieve the list of attributes listed by strong_parameters
, as that's really the public face of my API.
What I would like to do:
def MyController < ApplicationController
# ...CRUD actions...
private
def my_params
require(:resource).permit(:first_name, :last_name, :age)
end
end
MyController.my_params => [:first_name, :last_name, :age]
Typically the listing is marked as private
, so that's the first issue. I don't want to maintain 2 separate lists of attributes for a resource, so I would really like to access the actual values permitted by the code to keep my automated documentation accurate.
So far it looks like the params listing is not accessible outside the controller.