# Problem with url\_for and https - overrides all options

**URL:** <https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321>\
**Category:** Rails\
**Created:** [February 21, 2007, 1:59pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321 "2007-02-21T13:59:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 21, 2007, 1:59pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321/1 "2007-02-21T13:59:01Z")

</div>

I have a piece of code like this in one of my views:

\<%=link\_to “link here”, :action=\>‘my\_action’, :id=\>1 %\>

It works fine on my local development machine, running Webrick over http  
and it works fine on my testing server which is running single mongrel  
instance behind Apache 1.3 as a proxy. On both the outcome link is this:

[link here](https://www.ruby-forum.com/my_controller/action/1)

However having deployed it to my live server, which is running a  
mongrel\_cluster behind Apache 2.2 and mod\_proxy\_balancer. That one just  
gives the following:

[link here](https://www.mysite.com/my_controller)

Both the development server and the live one are running over https and  
they’re both running the same versions of everything so I’m guessing  
it’s something about how the https variable is being passed on the live  
server (where I am able to use the X\_FORWARDED\_PROTO ‘https’ header  
rather than having to set it manually as I do on the testing server.

Aside from a few minor configuration differences (mostly database  
connection strings) the two versions of the application are the same SVN  
revision and entirely identical.

All help welcome, I’m starting to get very confused here.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 21, 2007, 2:07pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321/2 "2007-02-21T14:07:58Z")

</div>

Ben M. wrote:

> Both the development server and the live one are running over https and  
> they’re both running the same versions of everything so I’m guessing  
> it’s something about how the https variable is being passed on the live  
> server (where I am able to use the X\_FORWARDED\_PROTO ‘https’ header  
> rather than having to set it manually as I do on the testing server.

Quick revision to my own comment here: It is nothing to do with the  
https stuff as I have exactly the same problem when I run it over http  
as I was having with https.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 21, 2007, 2:35pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321/3 "2007-02-21T14:35:04Z")

</div>

Ben M. wrote:

> I have a piece of code like this in one of my views:
> 
> \<%=link\_to “link here”, :action=\>‘my\_action’, :id=\>1 %\>

Another addendum, the problem is in url\_for and it only comes up in the  
view-

url\_for :action=\>‘my\_action’, :id=\>1

returns the correct url if called from my action and the incorrect one  
if called from the view.

If I make a call from the view to @controller.send(:url\_for, options)  
(which is the method that action\_view::url\_helper makes) it works  
correctly, but if I comment everything else out in  
action\_view::url\_helper.url\_for aside from that line it doesn’t work in  
spite of the fact there’s no real difference to the calls.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 21, 2007, 3:02pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321/4 "2007-02-21T15:02:41Z")

</div>

First thing I’d do is specify the controller name and see if that fixes  
the  
problem. I run into this all the time with partials.

\<%=link\_to “link here”, :action=\>‘my\_action’, :id=\>1 %\>

try

\<%=link\_to “link here”, :controller=\>“whatevver”, :action=\>‘my\_action’,  
:id=\>1 %\>

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 21, 2007, 4:08pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321/5 "2007-02-21T16:08:39Z")

</div>

Brian H. wrote:

> First thing I’d do is specify the controller name and see if that fixes  
> the  
> problem. I run into this all the time with partials.
> 
> \<%=link\_to “link here”, :action=\>‘my\_action’, :id=\>1 %\>
> 
> try
> 
> \<%=link\_to “link here”, :controller=\>“whatevver”, :action=\>‘my\_action’,  
> :id=\>1 %\>

Makes no difference I’m afraid. Still just links to the controller name  
with no action specified.

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [February 21, 2007, 4:19pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321/6 "2007-02-21T16:19:11Z")

</div>

Ben M. wrote:

> Ben M. wrote:
> 
> > I have a piece of code like this in one of my views:
> > 
> > \<%=link\_to “link here”, :action=\>‘my\_action’, :id=\>1 %\>
> 
> Another addendum, the problem is in url\_for and it only comes up in the  
> view-
> 
> url\_for :action=\>‘my\_action’, :id=\>1
> 
> returns the correct url if called from my action and the incorrect one  
> if called from the view.
> 
> If I make a call from the view to @controller.send(:url\_for, options)  
> (which is the method that action\_view::url\_helper makes) it works  
> correctly, but if I comment everything else out in  
> action\_view::url\_helper.url\_for aside from that line it doesn’t work in  
> spite of the fact there’s no real difference to the calls.

Further to this I actually went into actionview/helpers/url\_helper.rb  
and put a bunch of logging in to find what exactly was in the “options”  
hash being passed to the controller. When I put the logging in, it  
worked fine.

When I took the logging out again, it still worked.

That’s kind of good news, in that the application is working now, but a  
little bit worrying because I don’t have much clue what the problem was  
or how I can deal with it if it happens again (?except maybe putting the  
logging back in?) which is a bit nerve-wracking in a production  
server…

---

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [May 10, 2007, 5:42pm UTC](https://www.ruby-forum.com/t/problem-with-url-for-and-https-overrides-all-options/86321/7 "2007-05-10T17:42:51Z")

</div>

In conclusion to this, I think the problem was due to the  
edgesoft\_no\_cookie plugin which I had installed but wasn’t actually  
implementing anywhere in my system.
