undefined method `opts' for nil:NilClass
Closed this issue · 2 comments
shanecav84 commented
The following results in the error when making any request. Moving Roda.plugin :type_routing
under App
using plugin :type_routing
does not cause an error.
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'roda', '3.22.0'
end
require 'roda/session_middleware'
Roda.plugin :type_routing
class App < Roda
# Replace `Roda.plugin :type_routing` with this
# plugin :type_routing
require 'securerandom'
use RodaSessionMiddleware, secret: SecureRandom.alphanumeric(64)
route do |r|
r.root do
r.get { '' }
end
end
end
run App.app
NoMethodError: undefined method `opts' for nil:NilClass
.../roda-3.22.0/lib/roda/plugins/type_routing.rb:178:in `_remaining_path'
.../roda-3.22.0/lib/roda.rb:684:in `initialize'
.../roda-3.22.0/lib/roda/session_middleware.rb:165:in `new'
.../roda-3.22.0/lib/roda/session_middleware.rb:165:in `call'
.../rack-2.0.7/lib/rack/tempfile_reaper.rb:15:in `call'
.../rack-2.0.7/lib/rack/lint.rb:49:in `_call'
.../rack-2.0.7/lib/rack/lint.rb:37:in `call'
.../rack-2.0.7/lib/rack/show_exceptions.rb:23:in `call'
.../rack-2.0.7/lib/rack/common_logger.rb:33:in `call'
.../rack-2.0.7/lib/rack/chunked.rb:54:in `call'
.../rack-2.0.7/lib/rack/content_length.rb:15:in `call'
.../rack-2.0.7/lib/rack/handler/webrick.rb:86:in `service'
.../webrick/httpserver.rb:140:in `service'
.../webrick/httpserver.rb:96:in `run'
.../webrick/server.rb:307:in `block in start_thread'
::1 - - [04/Aug/2019:08:38:29 -0400] "GET / HTTP/1.1" 500 51984 0.0058
jeremyevans commented
Looks like roda/session_middleware does not work if you load the type_routing plugin into Roda itself, because SessionMiddleware doesn't allocate a Roda scope (for performance reasons). This could definitely be fixed by allocating a Roda scope in roda/session_middleware, but I think I can figure out a way to avoid that.
shanecav84 commented
Thank you!