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.
pablomarti
source share