質問編集履歴
1
ご指摘いただいたmodelは変更いたしました。また、一部名前変更しました。現在、トップ画面に遷移してほしいところ、結局ログイン画面のまま遷移できない状況です。
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,15 +26,19 @@
|
|
26
26
|
|
27
27
|
```ターミナル
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
Started GET "/login?utf8=%E2%9C%93&authenticity_token=mst4jXA4YTO%2F2Z60HMf19jl3ZZgH0tYhfrMMb73sGKvpXiote7%2FFThLdH2gipdTjxg%2Ff2JquEh5XSPn88XRAIg%3D%3D&email=test%40test.com&password=[FILTERED]&commit=%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3" for 10.0.2.2 at 2018-01-29 09:33:07 +0000
|
30
|
+
|
31
|
+
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
|
32
|
+
|
33
|
+
Processing by SessionsController#new as HTML
|
34
|
+
|
35
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"mst4jXA4YTO/2Z60HMf19jl3ZZgH0tYhfrMMb73sGKvpXiote7/FThLdH2gipdTjxg/f2JquEh5XSPn88XRAIg==", "email"=>"test@test.com", "password"=>"[FILTERED]", "commit"=>"ログイン"}
|
36
|
+
|
37
|
+
Rendering sessions/new.html.erb within layouts/application
|
38
|
+
|
39
|
+
Rendered sessions/new.html.erb within layouts/application (1.3ms)
|
40
|
+
|
41
|
+
Completed 200 OK in 268ms (Views: 238.2ms | ActiveRecord: 0.0ms)
|
38
42
|
|
39
43
|
|
40
44
|
|
@@ -52,19 +56,21 @@
|
|
52
56
|
|
53
57
|
|
54
58
|
|
55
|
-
root :to => '
|
59
|
+
root :to => 'sessions#new'
|
56
|
-
|
60
|
+
|
57
|
-
resources :
|
61
|
+
resources :sessions
|
58
62
|
|
59
63
|
resources :users, except: [:edit, :index]
|
60
64
|
|
61
65
|
resources :clients, except: [:show, :new, :edit]
|
62
66
|
|
63
|
-
|
67
|
+
resources :schedules, except: [:show, :new, :edit]
|
64
|
-
|
68
|
+
|
69
|
+
|
70
|
+
|
65
|
-
get 'login' => '
|
71
|
+
get 'login' => 'sessions#new', :as => :login
|
66
|
-
|
72
|
+
|
67
|
-
post 'logout' => '
|
73
|
+
post 'logout' => 'sessions#destroy', :as => :logout
|
68
74
|
|
69
75
|
get 'tops/index' => 'tops#index'
|
70
76
|
|
@@ -72,7 +78,9 @@
|
|
72
78
|
|
73
79
|
post 'clients/index' => 'clients#index'
|
74
80
|
|
75
|
-
get 'schedules/index'
|
81
|
+
get 'schedules/index' => 'schedules#index'
|
82
|
+
|
83
|
+
post 'schedules/index' => 'schedules#index'
|
76
84
|
|
77
85
|
|
78
86
|
|
@@ -104,21 +112,21 @@
|
|
104
112
|
|
105
113
|
```controller
|
106
114
|
|
107
|
-
class
|
115
|
+
class SessionsController < ApplicationController
|
108
|
-
|
109
|
-
|
116
|
+
|
117
|
+
|
110
118
|
|
111
119
|
def new
|
112
120
|
|
113
|
-
@user = User.new
|
114
|
-
|
115
121
|
end
|
116
122
|
|
117
123
|
|
118
124
|
|
119
125
|
def create
|
120
126
|
|
121
|
-
|
127
|
+
user = login(params[:email], params[:password])
|
128
|
+
|
129
|
+
if user
|
122
130
|
|
123
131
|
redirect_back_or_to tops_index_path, notice: "Login successful"
|
124
132
|
|
@@ -126,23 +134,27 @@
|
|
126
134
|
|
127
135
|
flash.now[:alert] = "Failed to login"
|
128
136
|
|
129
|
-
red
|
137
|
+
render action: 'new'
|
130
138
|
|
131
139
|
end
|
132
140
|
|
133
141
|
end
|
134
142
|
|
135
|
-
|
143
|
+
|
136
144
|
|
137
145
|
def destroy
|
138
146
|
|
139
147
|
logout
|
140
148
|
|
141
|
-
redirect_to
|
149
|
+
redirect_to root_path, notice: "Logged out!"
|
142
|
-
|
150
|
+
|
143
|
-
end
|
151
|
+
end
|
144
|
-
|
152
|
+
|
153
|
+
|
154
|
+
|
145
|
-
end
|
155
|
+
end
|
156
|
+
|
157
|
+
|
146
158
|
|
147
159
|
|
148
160
|
|
@@ -154,59 +166,43 @@
|
|
154
166
|
|
155
167
|
authenticates_with_sorcery!
|
156
168
|
|
157
|
-
|
158
|
-
|
159
|
-
|
169
|
+
|
160
|
-
|
161
|
-
|
170
|
+
|
162
|
-
|
163
|
-
|
171
|
+
|
164
172
|
|
165
173
|
validates :email, uniqueness: true
|
166
174
|
|
167
|
-
|
175
|
+
validates :password, length: { minimum: 6 }, if: -> { new_record? || changes["password"] }
|
176
|
+
|
168
|
-
|
177
|
+
validates :password, confirmation: true, if: -> { new_record? || changes["password"] }
|
178
|
+
|
179
|
+
validates :password_confirmation, presence: true, if: -> { new_record? || changes["password"] }
|
180
|
+
|
169
|
-
end
|
181
|
+
end
|
182
|
+
|
183
|
+
|
170
184
|
|
171
185
|
```
|
172
186
|
|
173
187
|
```view
|
174
188
|
|
175
|
-
|
189
|
+
class User < ApplicationRecord
|
176
|
-
|
190
|
+
|
177
|
-
|
191
|
+
authenticates_with_sorcery!
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
178
|
-
|
197
|
+
validates :email, uniqueness: true
|
198
|
+
|
179
|
-
|
199
|
+
validates :password, length: { minimum: 6 }, if: -> { new_record? || changes["password"] }
|
180
|
-
|
181
|
-
|
200
|
+
|
182
|
-
|
183
|
-
|
201
|
+
validates :password, confirmation: true, if: -> { new_record? || changes["password"] }
|
184
|
-
|
185
|
-
|
202
|
+
|
186
|
-
|
187
|
-
<div class="iconemail"></div>
|
188
|
-
|
189
|
-
|
203
|
+
validates :password_confirmation, presence: true, if: -> { new_record? || changes["password"] }
|
190
|
-
|
191
|
-
|
204
|
+
|
192
|
-
|
193
|
-
<div class="fieldbox">
|
194
|
-
|
195
|
-
<div class="iconpassword"></div>
|
196
|
-
|
197
|
-
<%= password_field_tag :crypted_password, params[:crypted_password], :placeholder => "Password", class: "field" %>
|
198
|
-
|
199
|
-
</div>
|
200
|
-
|
201
|
-
<%= submit_tag "ログイン", :class => "login-submit" %>
|
202
|
-
|
203
|
-
<%= link_to "Signup", tops_index_path %>
|
204
|
-
|
205
|
-
|
205
|
+
end
|
206
|
-
|
207
|
-
</form>
|
208
|
-
|
209
|
-
</fieldset>
|
210
206
|
|
211
207
|
|
212
208
|
|