diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-03-28 03:05:14 +0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-03-28 04:58:47 +0800 |
commit | 7cbdfa83035aacb0d4dbfa84525b54e9122efb75 (patch) | |
tree | 9dea7eb6505377b5360c3447ecc19f6d30e06b2c /railties | |
parent | 84aab7aa53e0ec4430df89807aa8220353b2d0c9 (diff) | |
download | rails-7cbdfa83035aacb0d4dbfa84525b54e9122efb75.tar.gz rails-7cbdfa83035aacb0d4dbfa84525b54e9122efb75.tar.bz2 rails-7cbdfa83035aacb0d4dbfa84525b54e9122efb75.zip |
Add controller-specific `force_ssl` method to force web browser to use HTTPS protocol
This would become useful for site which sometime transferring sensitive information such as account information on particular controller or action.
This featured was requested by DHH.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/action_controller_overview.textile | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index ecb03a48e4..178d98c2d6 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -816,6 +816,28 @@ end NOTE: Certain exceptions are only rescuable from the +ApplicationController+ class, as they are raised before the controller gets initialized and the action gets executed. See Pratik Naik's "article":http://m.onkey.org/2008/7/20/rescue-from-dispatching on the subject for more information. +h3. Force HTTPS protocol + +Sometime you might want to force a particular controller to only be accessible via an HTTPS protocol for security reason. Since Rails 3.1 you can now use +force_ssl+ method in your controller to enforce that: + +<ruby> +class DinnerController + force_ssl +end +</ruby> + +Just like the filter, you could also passing +:only+ and +:except+ to enforce the secure connection only to specific actions + +<ruby> +class DinnerController + force_ssl :only => :cheeseburger + # or + force_ssl :except => :cheeseburger +end +</ruby> + +Please note that if you found yourself adding +force_ssl+ to many controllers, you may found yourself wanting to force the whole application to use HTTPS instead. In that case, you can set the +config.force_ssl+ in your environment file. + h3. Changelog * February 17, 2009: Yet another proofread by Xavier Noria. |