[英]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.