这个问题与SO question and answer (rails-3-ssl-deprecation )有关,它建议在rails 3中使用路由来处理ssl.rb和路由如下:
resources :sessions, :constraints => { :protocol => "https" }
# Redirect /foos and anything starting with /foos/ to https.
match "foos(/*path)", :to => redirect { |_, request| "https://" + request.host_with_port + request.fullpath }
My problem is that links use relative paths(i think thats the correct term) and once I'm on a https page all the other links to other pages on the site then use https.
1) 对于不需要https的页面,返回http的最佳方式是什么?我是否必须为所有这些设置重定向(我希望注意),还是有更好的方法.重定向是这样的吗:
match "foos(/*path)", :to => redirect { |_, request| "http://" + request.host_with_port + request.fullpath }
2) 如果需要重定向回http,我该如何处理这样一种情况:除了一个方法之外,我希望所有方法都是http?ie foos(/*路径)适用于所有foos方法.但是我想让foos/upload_foos使用ssl.我知道怎么要求
scope :constraints => { :protocol => "https" } do
match 'upload_foos' => 'foos#upload_foos', :via => :post, :as => :upload_foos
end
但是如果我把http重定向放在foos路径上,https上传会发生什么?