teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

大変失礼致しました。ご指摘ありがとうございます。修正いたしました。

2019/07/21 12:36

投稿

kntarohh
kntarohh

スコア11

title CHANGED
File without changes
body CHANGED
@@ -65,16 +65,17 @@
65
65
  ### ★app/mailers/user_mailer.rb
66
66
 
67
67
  ```
68
- <h1>Sample App</h1>
68
+ class UserMailer < ApplicationMailer
69
+ def account_activation(user)
70
+ @user = user
71
+ mail to: user.email
72
+ end
69
73
 
74
+ def password_reset(user)
75
+ @user = user
70
- <p>Hi <%= @user.name %>,</p>
76
+ mail to: user.email, subject: "Password reset"
71
-
72
- <p>
77
+ end
73
- Welcome to the Sample App! Click on the link below to activate your account:
74
- </p>
78
+ end
75
-
76
- <%= link_to "Activate", edit_account_activation_url(@user.activation_token,
77
- email: @user.email) %>
78
79
  ```
79
80
 
80
81
  ### ★app/models/user.rb

1

routesファイル追記しました。よろしくお願いいたします。

2019/07/21 12:36

投稿

kntarohh
kntarohh

スコア11

title CHANGED
File without changes
body CHANGED
@@ -150,6 +150,31 @@
150
150
  end
151
151
  ```
152
152
 
153
+ ### ★config/routes.rb
154
+ ```
155
+ Rails.application.routes.draw do
156
+
157
+ get 'password_resets/new'
158
+
159
+ get 'password_resets/edit'
160
+
161
+ get 'sessions/new'
162
+
163
+ root 'static_pages#home'
164
+ get '/help', to: 'static_pages#help'
165
+ get '/about', to: 'static_pages#about'
166
+ get '/contact', to: 'static_pages#contact'
167
+ get '/signup', to: 'users#new'
168
+ post '/signup', to: 'users#create'
169
+ get '/login', to: 'sessions#new'
170
+ post '/login', to: 'sessions#create'
171
+ delete '/logout', to: 'sessions#destroy'
172
+ resources :users
173
+ resources :account_activations, only: [:edit]
174
+ resources :password_resets, only: [:new, :create, :edit, :update]
175
+ end
176
+ ```
177
+
153
178
  ### 試したこと
154
179
 
155
180
  activation_token が nil であることが原因であると思うのですが、"account_activation"のテストはパスするので、user.rb の create_activation_digest が実行されていないとしたら原因がわかりません。。