I had request.env['http_host'] working on localhost, but it causes an error when linking to the hero page on the layout page.
This request works in the view and displays the correct base url, but it causes an error when moving the code to the layout. Note. I use this to create 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" %>
received error:
ActionView::Template::Error (undefined method `env' for nil:NilClass):
Bob cavezza
source share