Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7592847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:00:35+00:00 2026-05-30T21:00:35+00:00

I need to patch or overload Request.remote_ip (or would Request.ip be better as I

  • 0

I need to patch or overload Request.remote_ip (or would Request.ip be better as I see some mentioning that this should be used instead of remote_ip) such that it acts as normal, but if CF-Connecting-IP is in the header, it will return this IP address rather than the one it normally detects.

How do I set up this patch appropriately in terms of the class and method definition?

Essentially I’m trying to simply return the following for each request:

headers["CF-Connecting-IP"] || remote_ip
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:00:36+00:00Added an answer on May 30, 2026 at 9:00 pm

    I wouldn’t monkey patch a method on request. Instead, I’d make a helper method in your application controller that does exactly what you just posted:

    class ApplicationController < ActionController::Base
      ...
    
      def connecting_ip
        headers["CF-Connecting-IP"] || request.remote_ip
      end
    end
    

    And just use connecting_ip wherever this is important.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a small console app (patch) that turns off the print
If we need to issue a bug patch that does not include current development
I need to patch a class that is in a JA file, in a
I need to have a loop that can constantly check for this variable: NSString
I have this image for imagebutton, and i need to create patch 9 of
I need some help setting up a particular terrain. I have a world that
I'm not a java guy but I've inherited some code I need to patch
I have cloned a project that includes some .csproj files. I don't need/like my
I need a patch utility which generates an exe file from the differences of
We need to patch an assembly and we can't rebuild from source code at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.