Ssl

Hi all,

I have just enabled SSL on my HTTPD installation and it is working
flawlessly. Even my rails app is working, and I did not change one
line of code in it.

I access my app trought HTTPS and every link on it keeps the HTTPS as
protocol.

But the problem is that wherever I use redirect_to on my app, it
redirects to HTTP, and not HTTPS. I thought it would use the current
protocol…

How can I fix that?

Adding: I want SSL to be enabled on the whole application, and not
only on a few actions/controllers. It is already working like that,
just redirect_to doesn’t seem to work.

My guess is that you’re using url_for() to redirect and that Rails
itself isn’t managing the SSL but some other process on your server
(pound, in our case).

So, for us, and I’m guessing you too, Rails has no idea it’s behind an
SSL connection. That that means that url_for generates a http: path
instead of https:.

If this is all true for you, you can use path_for instead of url_for.
path_for generates a relative path instead of a full url including the
protocol, which if linking inside your application, should work fine.
Another option is to pass the :only_path => true argument to url_for. A
third option is to just pass a hash to redirect_to, such as…

redirect_to :controller => ‘people’, :action => ‘show’, :id =>
@person.id

And lastly, if you’re using RESTful routes, you can just…

redirect_to person_path(@person)

[email protected] wrote:

redirects to HTTP, and not HTTPS. I thought it would use the current
protocol…

How can I fix that?


http://www.5valleys.com/
http://www.workingwithrails.com/person/8078