Reputation: 1019
How do I add ".json" to a Sinatra route which includes a named parameter such as
get '/view/:name'
?
I thought get '/view/:name.json' might work but I get an "Unable to access path /view/name.json" exception.
Upvotes: 1
Views: 1452
Reputation: 18716
This code works perfectly:
get '/hello/:name.json' do
"Hello #{params[:name]}"
end
=> /hello/samy.json outputs "Hello samy"
Please show the complete stack trace of your exception.
Upvotes: 1