Using double-quotes here will not do what you want - they get evaluated when the routes file is loaded, not per-request. For this case, the block form of redirect is probably what you want:
get 'jokes/:number', to: redirect { |params, request |
path = (params[:number].to_i.even? ? "wheres-the-beef" : "i-love-lamp" )
"http://#{request.host_with_port}/#{path}"
}
See the docs for ActionDispatch::Routing::Redirection for more info.