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

  • SEARCH
  • Home
  • 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 7685595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:17:10+00:00 2026-05-31T19:17:10+00:00

I had request.env[‘http_host’] working on localhost, but it causes an error when referenced in

  • 0

I had request.env['http_host'] working on localhost, but it causes an error when referenced in a layout page on heroku.

This request works in a view and displays the correct base url, but it causes an error when I move the code to the layout. Note – I’m using this to build absolute urls for images in html emails.

  <%= "#{request.env['HTTP_HOST']}/assets/email_header_image.png" %> 
  <%= image_tag "#{request.env['HTTP_HOST']}/assets/email_header_image.png" %>

error received:

ActionView::Template::Error (undefined method `env' for nil:NilClass):
  • 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-31T19:17:11+00:00Added an answer on May 31, 2026 at 7:17 pm

    If you want the host without the port, just use:

    request.host
    

    edit: Oops, I’ve just noticed that you’re using the code in the view. I don’t know if it is visible over there, I’ve only used it in controllers, but that’s fairly simple to overcome by setting an instance variable.

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

Sidebar

Related Questions

So far I have been creating Web Portal but recently I had a request
Had a page that was working fine. Only change I made was to add
I had code like this in Ruby: @clientipaddress = request.env[HTTP_CLIENT_IP] if (@clientipaddress == nil)
I had the page name as the-book.html, but now i changed the page name
We've had an interesting request from a client. They'd like their users to have
Had a good search here but can't see anything that gets my mind in
Had this working; at one stage. The problem is the following text is now
Ok, I have had a request to implement the same function that the weather
Recently, I've had a request to implement logging for all of the Controller classes
I never heard of a .do file. I had a request from some one

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.