Closed
Description
As I understood it, the before
and route
blocks share the same scope (which is why you can set an instance variable in the before
filter and have it respected in the route
). I've noticed, however, that non query string params aren't picked up in the before
filter block. Take this example:
require 'sinatra'
before do
if params[:sucka]
@sucka = "set in before"
end
end
get '/hey/:sucka/sup' do
if params[:sucka] && !@sucka
@sucka = "set in route"
end
@sucka
end
If you hit /hey/man/sup
it's always set in route rather than the before
block, but it seems like it ought to be set in the before
block. Sorry for not having a patch for it, after looking through the code I was at a loss as to where this gets put together :/