Request.env not accessible in controller

Hi,

I have the simplest rails app:

my only controller says:

class MaxmindController < ApplicationController
@ip = request
end

my index.rhtml in the views/maxmind folder says:

<%= debug @ip %>

the result of trying to view this in firefox is:

NameError in MaxmindController#index

undefined local variable or method `request’ for
MaxmindController:Class

if I remove the one line from my controller and change my view code
to:

<%= debug request %>

then i get my request object nicely displayed.

Why is request available only in the view and not in the controller?
I’m running this locally under locomotive.

Thanks,

Gabor

Because you’re out of scope. @ip = request is in the class scope, and
request is not available there.

Try using a before_filter.

class MaxmindController < ApplicationController
before_filter :get_ip

protected
def get_ip
@ip = request.remote_ip
end

end