# Ssl\_required being ignored?

**URL:** <https://www.ruby-forum.com/t/ssl-required-being-ignored/122155>\
**Category:** Rails\
**Created:** [December 5, 2007, 12:25am UTC](https://www.ruby-forum.com/t/ssl-required-being-ignored/122155 "2007-12-05T00:25:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Big\_Dave\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@Big\_Dave\_S](https://www.ruby-forum.com/u/Big_Dave_S)\
**Post date:** [December 5, 2007, 12:25am UTC](https://www.ruby-forum.com/t/ssl-required-being-ignored/122155/1 "2007-12-05T00:25:44Z")

</div>

Hi everyone! I want to require SSL for a single action in one of my  
controllers (for logging in, and sending a password).

Working off of the skateboard book, I have added:  
include SslRequirement  
to my application controller, and then in the login controller, I have  
added the line:  
ssl\_required :login

This does not give me any errors, but it does not redirect me to https  
either. It simply acts like it did before I added those two lines.  
What have I missed?

I believe ssl is working on my server, as I can actually change any  
address in my app to https instead of http, and it works fine, but it  
seems to be ignoring the ssl\_required line. Here is a taste of what  
I’ve got:

class LoginController \< ApplicationController  
ssl\_required :login  
before\_filter :authorize, :except =\> [:login, :index]  
layout ‘public’

def login  
…  
end

…  
end

Any help would be greatly appreciated. Hopefully I’ve just missed  
something simple, but as I said, I’m using the example posed in the  
skateboard book, and it seems to be just that simple. Thank you!

---

<div class="post-metadata">

**Author:** ![Big\_Dave\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@Big\_Dave\_S](https://www.ruby-forum.com/u/Big_Dave_S)\
**Post date:** [December 6, 2007, 7:30am UTC](https://www.ruby-forum.com/t/ssl-required-being-ignored/122155/2 "2007-12-06T07:30:30Z")

</div>

Hi,

On Dec 4, 2007 6:25 PM, Big Dave S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This does not give me any errors, but it does not redirect me to https  
> before\_filter :authorize, :except =\> [:login, :index]  
> something simple, but as I said, I’m using the example posed in the  
> skateboard book, and it seems to be just that simple. Thank you!

You could try making all actions require ssl by adding the following to  
your  
application.rb

protected  
def ssl\_required?  
true  
end

I actually use the following in my code, so it does not require ssl when  
I’m  
in the development or test environment.

protected  
def ssl\_required?  
ENV[“RAILS\_ENV”] == “production”  
end

> > 
> 
> HTH,  
> Michael G.
