Is there a shortcut for this getting a response that returns an HTTP error?

I really don't know what to look for to get the answer to this question:

Is there a short arm for this block:

get '/' do
  501
end

I started with the rubymonk.com textbook, which meant that in most cases there was a generally accepted reduction in ruby, but I did not try the following:

get '/' 501
get '/' (501)
get '/' {501}
get '/' do 501
+3
source share
2 answers

Try the following:

get('/') { 501 }

There seems to be a problem with the Ruby syntax.

get '/' { 501 }( f g x) is apparently interpreted as get('/'({ 501 }))( f(g(x))), which is incorrect.

+1
source

I don’t know which version of Ruby you are using, possibly 1.8.7, on Ruby 1.9 and 2.1.0 the error reported for the code is get '/' { 501 }:

syntax error, unexpected '{', expecting $end

, { 501 } '/', get('\' { 501 }), , , . , '\':

get('/') { 501 }
+3

All Articles