Ruby on Rail by M.Hartl,第 10/11 章(activation/password 重置)错误
Ruby on Rail by M.Hartl, Chapter 10/11(activation/password reset) error
我是 RoR 的新手,正在关注 Michael Hartl 在 Rails 示例应用程序教程中的 Ruby。惠斯特完成第 10 章和第 11 章遇到了问题,我不确定如何解决。
我的所有测试都通过了,但是当通过 Heroku.com 使用该应用程序时,该应用程序将发送自动激活和密码重置电子邮件,但是当用户单击这些电子邮件中的 link网络浏览器被定向到 'untitled:blank' 页面。
有谁知道我该如何解决这个问题。请查看下面的一些相关代码,如果您还需要查看,请告诉我。
任何帮助将不胜感激。
非常感谢(提前)
费伊·马修斯
routes.rb =
1 Rails.application.routes.draw do
2 root 'static_pages#home'
3 get '/help', to: 'static_pages#help'
4 get '/about', to: 'static_pages#about'
5 get '/contact', to: 'static_pages#contact'
6 get '/signup', to: 'users#new'
7 get '/login', to: 'sessions#new'
8 post '/login', to: 'sessions#create'
9 delete '/logout', to: 'sessions#destroy'
10 resources :users
11 resources :account_activations, only: [:edit]
12 resources :password_resets, only: [:new, :create, :edit, :update]
13 end
user_mailer/password_reset.html.erb =
1 <h1>Password reset</h1>
2 <p>To reset you password click the link below:</p>
3
4 <%= link_to "Reset password", edit_password_reset_url(@user.reset_token,
5 email: @user.email) %>
6
7 <p> This link will expire in two hours.</p>
8
9 <p>
10 If you did not request your password to be reset, please ignore this email and your password will remain unchanged.
11 </p>
user_mailer/password_reset.text.erb =
1 To reset you password click the link below:
2
3 <%= edit_password_reset_url(@user.reset_token, email: @user.email) %>
4
5 This link will expire in two hours.
6
7 If you did not request you password to be reset, please ignore this email and your password will remain unchanged.
environments/production.rb =
60 config.action_mailer.raise_delivery_errors = true
61 config.action_mailer.delivery_method = :smtp
62 config.action_mailer.default_url_options = { :host => '<safe-falls-22225>.herokuapp.com' }
63 ActionMailer::Base.smtp_settings = {
64 :address => 'smtp.sendgrid.net',
65 :port => '587',
66 :authentication => :plain,
67 :user_name => ENV['SENDGRID_USERNAME'],
68 :password => ENV['SENDGRID_PASSWORD'],
69 :domain => 'heroku.com',
70 :enable_starttls_auto => true
71 }
在 config/environments/production.rb
中更改 line:62
config.action_mailer.default_url_options = { host: 'safe-falls-22225.herokuapp.com' }
你的 default_url_options
有错别字
我是 RoR 的新手,正在关注 Michael Hartl 在 Rails 示例应用程序教程中的 Ruby。惠斯特完成第 10 章和第 11 章遇到了问题,我不确定如何解决。
我的所有测试都通过了,但是当通过 Heroku.com 使用该应用程序时,该应用程序将发送自动激活和密码重置电子邮件,但是当用户单击这些电子邮件中的 link网络浏览器被定向到 'untitled:blank' 页面。
有谁知道我该如何解决这个问题。请查看下面的一些相关代码,如果您还需要查看,请告诉我。
任何帮助将不胜感激。
非常感谢(提前)
费伊·马修斯
routes.rb =
1 Rails.application.routes.draw do
2 root 'static_pages#home'
3 get '/help', to: 'static_pages#help'
4 get '/about', to: 'static_pages#about'
5 get '/contact', to: 'static_pages#contact'
6 get '/signup', to: 'users#new'
7 get '/login', to: 'sessions#new'
8 post '/login', to: 'sessions#create'
9 delete '/logout', to: 'sessions#destroy'
10 resources :users
11 resources :account_activations, only: [:edit]
12 resources :password_resets, only: [:new, :create, :edit, :update]
13 end
user_mailer/password_reset.html.erb =
1 <h1>Password reset</h1>
2 <p>To reset you password click the link below:</p>
3
4 <%= link_to "Reset password", edit_password_reset_url(@user.reset_token,
5 email: @user.email) %>
6
7 <p> This link will expire in two hours.</p>
8
9 <p>
10 If you did not request your password to be reset, please ignore this email and your password will remain unchanged.
11 </p>
user_mailer/password_reset.text.erb =
1 To reset you password click the link below:
2
3 <%= edit_password_reset_url(@user.reset_token, email: @user.email) %>
4
5 This link will expire in two hours.
6
7 If you did not request you password to be reset, please ignore this email and your password will remain unchanged.
environments/production.rb =
60 config.action_mailer.raise_delivery_errors = true
61 config.action_mailer.delivery_method = :smtp
62 config.action_mailer.default_url_options = { :host => '<safe-falls-22225>.herokuapp.com' }
63 ActionMailer::Base.smtp_settings = {
64 :address => 'smtp.sendgrid.net',
65 :port => '587',
66 :authentication => :plain,
67 :user_name => ENV['SENDGRID_USERNAME'],
68 :password => ENV['SENDGRID_PASSWORD'],
69 :domain => 'heroku.com',
70 :enable_starttls_auto => true
71 }
在 config/environments/production.rb
line:62
config.action_mailer.default_url_options = { host: 'safe-falls-22225.herokuapp.com' }
你的 default_url_options