rubycorns / rorganize.it

A web app to coordinate railsgirls project groups
https://rorganize.it
GNU Affero General Public License v3.0
41 stars 23 forks source link

Return client-side Error when nonsense country/ city is given #633

Closed lislis closed 6 years ago

lislis commented 6 years ago
An ActionView::Template::Error occurred in groups#index:

  undefined method `name' for nil:NilClass
  app/helpers/application_helper.rb:29:in `country_name_from_code'

If a nonsense city or country is given in the location filter, this ^ bit returns a 500. It seems nasty people try to bring down our site by exploiting this, so we should return a 400 status code here.

lislis commented 6 years ago

something similar to this maybe

rescue_from ActionController::ParameterMissing do
  render :nothing => true, :status => :bad_request
end

from https://stackoverflow.com/questions/20810660/trying-to-get-a-post-to-return-400-bad-request