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

質問編集履歴

2

追記

2020/07/31 04:15

投稿

no1knows
no1knows

スコア3365

title CHANGED
File without changes
body CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  メールのアクティベーションリンクをクリックしたら、アクティベーションが成功し、ログインした状態にすることは可能でしょうか?
4
4
 
5
- 下記のようにUserSessionsコントローラーにあったloginメソッドを追加したのですが、ログインできませんでした。
5
+ 下記のようにUserSessionsコントローラーにあったloginメソッドを追加したのですが、ログインできず、アクティベーションされていただけでした。
6
+ ※エラーも表示されませんでした。
6
7
  ```Ruby
7
8
  class UsersController < ApplicationController
8
9
  skip_before_action :require_login, :only => [:index, :new, :create, :activate]
@@ -11,7 +12,7 @@
11
12
  def activate
12
13
  if @user = User.load_from_activation_token(params[:id])
13
14
  @user.activate!
14
- @user = login( @user.email, @user.crypted_password )
15
+ @user = login( @user.email, @user.crypted_password )
15
16
  redirect_to(login_path, :notice => 'User was successfully activated.')
16
17
  else
17
18
  not_authenticated

1

追記

2020/07/31 04:15

投稿

no1knows
no1knows

スコア3365

title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,22 @@
1
1
  SorceryのUserActivationサブモジュールを使っています。
2
2
 
3
- メールのアクティベーションリンクをクリックしたら、アクティベーションが成功し、ログインした状態にすることは可能でしょうか?
3
+ メールのアクティベーションリンクをクリックしたら、アクティベーションが成功し、ログインした状態にすることは可能でしょうか?
4
+
5
+ 下記のようにUserSessionsコントローラーにあったloginメソッドを追加したのですが、ログインできませんでした。
6
+ ```Ruby
7
+ class UsersController < ApplicationController
8
+ skip_before_action :require_login, :only => [:index, :new, :create, :activate]
9
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
10
+
11
+ def activate
12
+ if @user = User.load_from_activation_token(params[:id])
13
+ @user.activate!
14
+ @user = login( @user.email, @user.crypted_password )
15
+ redirect_to(login_path, :notice => 'User was successfully activated.')
16
+ else
17
+ not_authenticated
18
+ end
19
+ end
20
+ ```
21
+
22
+ どうぞよろしくおねがいします。