Ruby on Rails: ssl_required: how to enable the whole application?

Is there an easy way to enable SSL throughout the application?

I am using rails 2.3.8

+7
source share
1 answer

By default, all your controllers should inherit from ApplicationController .

ssl_required actually supported by a protected method called ssl_required? , which determines whether SSL is required for this action. This implementation will force SSL to always be required in a production environment (but not otherwise, so you can still do development as usual).

 class ApplicationController < ActionController::Base # (... other stuff ...) protected def ssl_required? Rails.env.production? end end 

Depending on your environment, it may be possible that the upstream server is accessible only through HTTPS (for example, if you use Apache, you can configure it to not serve the application through port 80). It depends on your server settings.

+7
source

All Articles