Skip to content

Instantly share code, notes, and snippets.

@gudata
Forked from sanaumair/resultitemcontroller
Created March 22, 2012 09:07
Show Gist options
  • Save gudata/2157258 to your computer and use it in GitHub Desktop.
Save gudata/2157258 to your computer and use it in GitHub Desktop.
def validate params
[:manufacturer, :model, :country_code].each do |field|
incoming_param = params[field].blank? ? '' : params[field]
field_value = self.send(field).blank? ? '' : self.send(field)
if field_value != incoming_param
error = Api::Errors::BadRequest.new('Bad Request it should be like manufacturer-country_code-model')
raise error
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment