I’m expecting a GET request to come with parameters, and want to return an error response if the expected parameters aren’t included. How can I check that the parameter has been included and return an error response if it isn’t?
I’m trying to use an if statement, but don’t know what to set the check against for when there’s no parameter included in the GET request (i.e. the GET request is to /route or /route/);
get '/route/' do
@symbol = params['parameter'];
if @symbol == (what goes here?)
return "Parameter missing error"
else
myfunction
end
erb :view
end
I’m using the @symbol value in another IF statement within myfunction.
I’m not entirely clear on what you’re asking, but I’ll try to show you what I think you need: