![](/img/trans.png)
[英]Adding Devise to Rails app NoMethodError: undefined method `devise' for User (call 'User.connection' to establish a connection
[英]SSL cannot establish secure connection - with Rails 6 app using Devise in Heroku
正如標題所說,我有一個在 Heroku 中運行的 Rails 6 應用程序,具有 Heroku 提供的自動 SSL 證書。 一切正常,我可以訪問任何頁面,它使https
工作正常。 但是,有一個例外:當用戶注冊並收到 email 確認時,由於某種原因無法單擊鏈接(請參閱下面的截圖),即使您將鏈接復制並粘貼到新標簽中也會發生同樣的情況, 當然。
這是我在嘗試訪問 url https://my_domain.com/users/confirmation?confirmation_token=foobar
時得到的。
我的environments/production.rb
有這些設置:
Rails.application.configure do
# a few more non important things, and then:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'my_domain.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
config.force_ssl = true
config.action_mailer.default_url_options = { :host => 'my_domain.com' }
end
這就是它在 Heroku 中的樣子:
我有 Devise 的這些路線:
Rails.application.routes.draw do
devise_for :users, controllers: { registrations: 'users/registrations',
confirmations: 'users/confirmations' }
authenticated :user do
root to: "depots#index", as: :authenticated_root
end
root to: "public/welcome#index"
end
controller 看起來像這樣:
class Users::ConfirmationsController < Devise::ConfirmationsController
def after_confirmation_path_for(resource_name, resource)
sign_in(resource)
authenticated_root_path
end
end
你們有什么想法可能是錯的嗎? 如果沒有,關於如何解決這個問題的任何建議?
2020 年 8 月 4 日更新:
I had added this redirect to my domain but even though it works redirecting from grownis.com
to www.grownis.com
it doesn't for https://grownis.com
您的證書不是通配符證書。 請檢查此鏈接。
確認鏈接為https://grownis.com/users/confirmation?confirmation_token=CONRIMATION_TOKEN
您需要從非 www 重定向到 www 或購買通配符證書。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.