# When `param1` and `param2` are sent at the same time,
# a 400 - Invalid Request will be sent back to the client
def hello
hello_params = params.require(:key).permit(:param1, :param2)
# Return 400 - Invalid Request if both params are present
if hello_params[:param1] && hello_params[:param2]
render json: { message: "Both param1 and param2 should not be sent together." }, status: 400
return
end
render json: { message: "Hello, world!" }
end
2条答案
按热度按时间xzv2uavs1#
允许它们两者并在控制器中验证您的逻辑怎么样?
字符串
qij5mzcb2#
我会这样做。这将允许
:params1
,如果它存在于参数中,否则:param2
。字符串