Forum: Ruby on Rails ssl_requirement plugin: how do I override ssl_required?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ce472655bd6e818fe8b5fd0ae57e45af?d=identicon&s=25 Scott Eade (seade)
on 2006-01-24 00:37
The ssl_requirement plugin indicates that I can override the
ssl_required? method.  I want to use this facility to ignore the ssl
requirement declarations when RAILS_ENV is anything other than
'production'.

My question is, where do I override this?

The relevant readme is:
http://dev.rubyonrails.org/browser/plugins/ssl_req...

Also, does this plugin work with a WEBrick based development environment
running on port 3000?  It looks like it is totally dropping the port
from the url.

TIA,
Scott
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-01-24 01:15
(Received via mailing list)
On Jan 23, 2006, at 4:37 PM, Scott Eade wrote:

> The ssl_requirement plugin indicates that I can override the
> ssl_required? method.  I want to use this facility to ignore the ssl
> requirement declarations when RAILS_ENV is anything other than
> 'production'.
>
> My question is, where do I override this?

You could do it in your ApplicationController:

   class ApplicationController < ActiveRecord::Base
     include SslRequirement

     alias :original_ssl_required? :ssl_required?
     def ssl_required?
       my_custom_condition_met? || original_ssl_required?
     end
   end

>
> The relevant readme is:
> http://dev.rubyonrails.org/browser/plugins/ssl_req...
>
> Also, does this plugin work with a WEBrick based development
> environment
> running on port 3000?  It looks like it is totally dropping the port
> from the url.

The SSL redirects assume that https maps to port 443. You would need
to have a webrick running on port 3000 and port 443 (with port 443
being the secure port).

- Jamis
This topic is locked and can not be replied to.