It looks like the code that should be in the model, so I guess where this method is. If so, you cannot (at least "out of the box") access the request object from your model, since it comes from an HTTP request - this is also the reason you get a "<90" local variable or method "request", from the main "in the console.
If this method was not in your model yet, I would place it there, then call it from the controller and pass it to request.remote_ip as an argument.
def get_location_users(the_ip) if current_user return current_user.location_users else l = Location.find_by_ip(the_ip) lu = LocationUser.new({:location_id => l.id, :radius => Setting.get("default_radius").to_i}) return [lu] end end
Then in your controller ::
SomeModel.get_location_users(request.remote_ip)
Also, keep in mind that "Location.find_by_ip" will return null if the entries do not match.
And you can send the request to the console using app.get "some-url" , then you can access request_ip from the request object app.request.remote_ip and use it for testing if necessary.
source share