Forum: Ruby on Rails undefined method `protocol' for nil:NilClass

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B9f28a2235697025ebfcebb81575a6b8?d=identicon&s=25 dba (Guest)
on 2005-11-12 19:10
(Received via mailing list)
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? :-)

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)
1b83454abeeb627eb42abc214ebbae00?d=identicon&s=25 nseckar (Guest)
on 2005-11-13 07:14
(Received via mailing list)
On 12-Nov-05, at 1:06 PM, Allen Fair 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.
B9f28a2235697025ebfcebb81575a6b8?d=identicon&s=25 dba (Guest)
on 2005-11-13 14:56
(Received via mailing list)
> 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. :-( Other controllers work
fine. I will hunt further.
This topic is locked and can not be replied to.