I want to redirect to 404 if request url contains invalid parameters, but I did not know what is the best way to achieve that.
For example: 
The request url: http://example.com/a_path/?invalid_parameter=foo
In this case, I want rails return 404. My stupid way is iterating params and check if contains invalided keys:
def redirect_404_if_invalid_params
  valid_params = [:valid_key_1, :valid_key_2, :valid_key_3]
  params.each do |key, value|
    if !valid_params.include?(key)
      redirect 404
    end
  end
end
But is there any better way to do this trick? Thanks.
 
     
     
     
    