相關:Rails 3 SSL routing redirects from https to http(不幸沒有工作)。我應該如何使所有Devise路徑使用https?
複製,但得到的答覆並沒有爲我工作:setting up ssl on devise
我有一個已經工作了一段時間,現在罰款的web應用程序,但我需要添加SSL登錄/編輯ACCT路徑。我正在使用Devise進行身份驗證。我在devise wiki中發現了一個條目,使得這個過程看起來非常簡單,但是如果我能使它工作,該死的。簡單的部分是這樣的:
#in config/environments/production.rb
config.to_prepare { Devise::SessionsController.force_ssl }
config.to_prepare { Devise::RegistrationsController.force_ssl }
然後還有約25行代碼,在這個要點:https://gist.github.com/1040964
我得到的工作做得不夠好,但是當過我登出我從拿到301會話DELETE將我發送到GET的操作。
Started DELETE "https://stackoverflow.com/users/sign_out" for 98.246.164.160 at 2012-03-02 01:45:42 +0000
[02 Mar 01:45 10886 INFO] Processing by Devise::SessionsController#destroy as HTML
[02 Mar 01:45 10886 INFO] Parameters: {"authenticity_token"=>"fI4VZ4V0Go2Civo3sJz8Dv5/Wtaa90ynaYr+xxx="}
[02 Mar 01:45 10886 DEBUG] Parameters: {"_method"=>"delete", "authenticity_token"=>"fI4VZ4V0Go2Civo3sJz8Dv5/Wtaa90ynaYr+xxxx=", "action"=>"destroy", "controller"=>"devise/sessions"}
[02 Mar 01:45 10886 INFO] Redirected to https://ec2-xx-xx-106-255.us-west-2.compute.amazonaws.com/users/sign_out
[02 Mar 01:45 10886 INFO] Completed 301 Moved Permanently in 3ms
Started GET "https://stackoverflow.com/users/sign_out" for xx.xx.164.160 at 2012-03-02 01:45:42 +0000
[02 Mar 01:45 10886 FATAL]
ActionController::RoutingError (No route matches [GET] "https://stackoverflow.com/users/sign_out"):
所以我覺得我需要從頭開始。使任何Devise路徑使用https最簡單的方法是什麼,但我的應用程序中的其餘路徑使用http?我試過這個(來自SO頂部的帖子):
#devise routes
scope :protocol => 'https://', :constraints => { :protocol => 'https://' } do
devise_for :users, :controllers => { :registrations => :registrations }
devise_for :admins
end
但是不行。我需要一個更好的建議。但