Undefined method `protocol' for nil:NilClass

Hi! This may have been answered somewhere before, but my searches turned
up nothing.

I am developing a Rails app that generally works, but just generated a
new controller (“list” controller), did not add anything, and when I go
to
http://localhost:3000/list/
I receive an error. It appears that the page was properly generated, but
somewhere preparing the result raised this exception

  undefined method `protocol' for nil:NilClass

(The protocol method returns either http: or https:) I have other
controllers that work fine, but I’ve been stumped with this one. I am
pasting the error page and development log below. Versions are in the
trace.

Does anyone know the cause, or have an idea/hint/solution for this? :slight_smile:

Thanks!
Allen

======= Error Page:

NoMethodError in List#index

undefined method `protocol’ for nil:NilClass

script/server:49

======= development.log:

Processing ListController#index (for 127.0.0.1 at Sat Nov 12 10:29:43
EST 2005)
Parameters: {“action”=>“index”, “controller”=>“list”}
Rendering within layouts/application
Rendering list/index (200 OK)

NoMethodError (undefined method `protocol’ for nil:NilClass):

/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/whiny_nil.rb:30:in
`method_missing’

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:807:in
`complete_request_uri’

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:45:in
`perform_action_without_rescue’

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in
`perform_action’

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in
process' /usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in dispatch’

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/webrick_server.rb:105:in
`handle_dispatch’

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/webrick_server.rb:71:in
service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service’
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread’
/usr/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in start’
/usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:in start’
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start’

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/webrick_server.rb:57:in
`dispatch’
script/server:49

Rendering
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/templates/rescues/layout.rhtml
(500 Internal Error)

On 12-Nov-05, at 1:06 PM, Allen F. wrote:

 undefined method `protocol' for nil:NilClass

(The protocol method returns either http: or https:) I have other
controllers that work fine, but I’ve been stumped with this one. I
am pasting the error page and development log below. Versions are
in the trace.

It looks like the request method for your controller is returning nil
instead of a request instance. Make sure that you don’t assign
anything to @request, and also ensure that you haven’t redefined
request.

It looks like the request method for your controller is returning nil
instead of a request instance. Make sure that you don’t assign anything
to @request, and also ensure that you haven’t redefined request.

Thanks for the suggestion. However, this is happening on a
newly-generated controller, with empty method definition and default
view template. I have added no code yet. :frowning: Other controllers work
fine. I will hunt further.