Hi,
I have the following app (which worked in sinatra < 2.0):
class App < Sinatra::Base register Sinatra::Namespace namespace '/foo/:year/?:period?' do get '/status' do status 200 end namespace '/nested' do get '/1' do this_method_does_not_exist('hello') status 200 end helpers do def this_method_does_not_exist(msg) puts "hello #{msg}" end end end end end
When I call /foo/2018/2/nested/1
all works as expected. When I call /foo/2018/nested/1
it results in a
NoMethodError: undefined method `this_method_does_not_exist`
Duplicating the outer namespace "resolves" the issue:
class App < Sinatra::Base register Sinatra::Namespace namespace '/foo/:year/?:period?' do get '/status' do status 200 end end namespace '/foo/:year/?:period?/nested' do get '/1' do this_method_does_not_exist('hello') status 200 end helpers do def this_method_does_not_exist(msg) puts "hello #{msg}" end end end end
Full test case can be found here: https://github.com/lvonk/sinatra-namespaces-issue
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4