Rails, is it possible to use SSL partially

Is it possible to use HTTP for some request and https for other requests for one rail server, for example

http://i.mysite.com/ 

and

 https://mysite.com/ 

thanks

0
ruby ruby-on-rails ruby-on-rails-3
source share
1 answer

Yes:

 before_filter :https_redirect def https_redirect if request.ssl? && !use_https? || !request.ssl? && use_https? protocol = request.ssl? ? "http" : "https" flash.keep redirect_to protocol: "#{protocol}://", status: :moved_permanently end end def use_https? controller_name == "abc" end 

(I take this code from some place, I don’t remember, so I can’t give loans ... but I use it in the project, and it works).

UPDATE: I am taking the code from RailsCasts haha, so thanks to Ryan Bates.

+1
source share

All Articles