I have an API that is pretty reassuring, but I'm struggling to figure out how to do the search. I want to be able to search all records between two dates, time dates can be no more than 6 hours apart. At the moment, in my controller method, I have the following:
required_params = [:start_time, :end_time]
if check_required_params(required_params, params) and check_max_time_bound(params, 6.hours)
... rest of controller code here ...
end
check_required_params is an application method that looks like this:
def check_required_params(required_params, params_sent)
required_params.each do |param|
unless has_param(param, params_sent)
unprocessable_entity
return false
end
end
true
end
check_max_time is pretty similar.
I know this against best practices for checking in the controller, but I don’t see how I can add it to the model.
Mike source
share