What does Sinatra return when no parameter is included in the route, but a symbol is set to match the parameter?

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.

Answers


I'm not entirely clear on what you're asking, but I'll try to show you what I think you need:

get '/route/' do
    @symbol = params['parameter'];
    if params.key.include?('parameter')
        myfunction
    else
      return 'Parameter missing error'
    end
    erb :view
end

Need Your Help

How do i populate a div in parent html/php from an ajax loaded child php

jquery ajax post html parent

Let's say i have an index.php that has html in it that looks like this:

Darkening <section> on one-page website

javascript jquery html5 css3

I am a semi-noob at web dev, however I am either searching with the wrong terms or I am not a very proficient googler.