Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Like elektronaut indicated, this is probably something that should be handled in your proxy's configuration. That said, ActiveSupport::UrlFor#url_for has some information that might be useful. Take a look at <a href="http://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/routing/url_for.rb" rel="nofollow noreferrer">http://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/routing/url_for.rb</a></p> <p>What I think it boils down to is passing two arguments into your url_for and/or link_to calls. First is the <code>:port =&gt; 123</code> argument, the second is <code>:only_path =&gt; false</code> so that it generates the full link including domain, port, etc.</p> <p>So when generating a link, you might do:</p> <pre><code>link_to 'test', root_url(:port =&gt; 80, :only_path =&gt; false) </code></pre> <p>and when creating a custom url you might do:</p> <pre><code>url_for :controller =&gt; 'test', :action =&gt; 'index', :port =&gt; 80, :only_path =&gt; false </code></pre> <p>For a redirect:</p> <pre><code>redirect_to root_url(:port =&gt; 80, :only_path =&gt; false) </code></pre> <p>I hope this helps, and if it doesn't, can you be more specific about how you generating your URLs, what rails is generating for you, and what you would like it to generate.</p> <p><strong>Update:</strong> I wasn't aware of this, but it seems you can set defaults for the URL's rails generates with url_for, which is used by everything else that generates links and/or URLs. There is a good write up about it here: <a href="http://lucastej.blogspot.com/2008/01/ruby-on-rails-how-to-set-urlfor.html" rel="nofollow noreferrer">http://lucastej.blogspot.com/2008/01/ruby-on-rails-how-to-set-urlfor.html</a></p> <p>Or to sum it up for you:</p> <p>Add this to your <code>application_controler.rb</code></p> <pre><code>def default_url_options(options) { :only_path =&gt; false, :port =&gt; 80 } end </code></pre> <p>and this:</p> <pre><code>helper_method :url_for </code></pre> <p>The first block sets defaults in the controllers, the second causes the url_for helper to use the one found in the controllers, so the defaults apply to that as well.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload