質問編集履歴
1
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,8 +7,10 @@
|
|
7
7
|
SSL_connect returned=1 errno=0 state=error: wrong version number
|
8
8
|
```
|
9
9
|
とのエラーが出ていて、
|
10
|
-
ググったとこと、SSL証明書が必要?な気がする
|
10
|
+
ググったとこと、、Ruby(Net::HTTP?)が SSL証明書を見つけることができなくて、HTTPS 接続に失敗しているのが原因らしい,SSL証明書が必要?な気がする
|
11
11
|
|
12
|
+
ユーザーを新規登録する際にエラーが出ます
|
13
|
+
|
12
14
|
### 該当のソースコード
|
13
15
|
|
14
16
|
```ruby
|
@@ -110,12 +112,140 @@
|
|
110
112
|
end
|
111
113
|
|
112
114
|
```
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
#users_controller.rb
|
118
|
+
|
119
|
+
class UsersController < ApplicationController
|
120
|
+
before_action :logged_in_user,only: [:index,:edit,:update,:destroy]
|
121
|
+
# メソッド名は基本シンボルで呼び出す
|
122
|
+
# 一回before_actionをコメントアウトして
|
123
|
+
# テストかけてちゃんと失敗するか確かめるべき
|
124
|
+
before_action :correct_user, only: [:edit,:update]
|
125
|
+
before_action :admin_user, only: :destroy
|
126
|
+
|
127
|
+
# => GET /users
|
128
|
+
def index
|
129
|
+
@users = User.paginate(page: params[:page])
|
130
|
+
# pageの中にpageが格納されていて、何番目
|
131
|
+
# のページにいるか取得できる
|
132
|
+
end
|
133
|
+
|
134
|
+
def show
|
135
|
+
@user = User.find(params[:id])
|
136
|
+
end
|
137
|
+
|
138
|
+
def new
|
139
|
+
@user = User.new
|
140
|
+
end
|
141
|
+
|
142
|
+
def create
|
143
|
+
@user = User.new(user_params)
|
144
|
+
if @user.save
|
145
|
+
# before_createでトークンがセットされてる
|
146
|
+
# => メールオブジェクトを生成する条件は
|
147
|
+
# 整ってる
|
148
|
+
UserMailer.account_activation(@user).deliver_now
|
149
|
+
# メイラーメソッド呼び出し
|
150
|
+
# deliver_nowは送信するメソッド
|
151
|
+
# 引数に渡されたユーザーに対して送信できるのかな?
|
152
|
+
flash[:info] = "Please check your email to activate your account."
|
153
|
+
redirect_to root_url
|
154
|
+
# log_in @user
|
155
|
+
# flash[:success] = "Welcome to the Sample App!!"
|
156
|
+
# redirect_to @user
|
157
|
+
# # user_path(@user)
|
158
|
+
# # user_path(@user.id)
|
159
|
+
# # user_path(1) => /users/1
|
160
|
+
else
|
161
|
+
render 'new'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# GET /users/:id/edit
|
166
|
+
def edit
|
167
|
+
@user = User.find(params[:id])
|
168
|
+
# => app/views/users/edit.html.erb
|
169
|
+
end
|
170
|
+
|
171
|
+
# PATCH /users/:id
|
172
|
+
def update
|
173
|
+
@user = User.find(params[:id])
|
174
|
+
if
|
175
|
+
@user.update(user_params)
|
176
|
+
flash[:success] = "Profile update"
|
177
|
+
redirect_to @user
|
178
|
+
else
|
179
|
+
render 'edit'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def destroy
|
184
|
+
User.find(params[:id]).destroy
|
185
|
+
flash[:success] = "User deleted"
|
186
|
+
redirect_to users_url
|
187
|
+
end
|
188
|
+
|
189
|
+
private
|
190
|
+
# これよりしたに書いたメソッドはこのファイルの
|
191
|
+
# 外からアクセスできない(基本的に)
|
192
|
+
|
193
|
+
def user_params
|
194
|
+
params.require(:user).permit(:name,:email,:password,:password_confirmation)
|
195
|
+
end
|
196
|
+
|
197
|
+
# ログインしてなかったらログインページに遷移する
|
198
|
+
def logged_in_user
|
199
|
+
unless logged_in?
|
200
|
+
# ログインしてるかどうか確かめるメソッド
|
201
|
+
store_location
|
202
|
+
# 遷移したいページを覚えとく
|
203
|
+
flash[:danger] = "Please log in."
|
204
|
+
redirect_to login_url
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def correct_user
|
209
|
+
@user = User.find(params[:id])
|
210
|
+
redirect_to(root_url) unless current_user?(@user)
|
211
|
+
# current_user?メソッド呼び出し
|
212
|
+
# form_withから受け取ったパラメーターのuserと
|
213
|
+
# セッションまたは、クッキーからのユーザー
|
214
|
+
# が一致してるかしてないか
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
def admin_user
|
219
|
+
redirect_to(root_url) unless current_user.admin?
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
```
|
113
226
|
### 試したこと
|
114
227
|
|
115
228
|
ググったらSSL証明書がないから、安全な通信を担保できないとかあったので
|
116
229
|
https://blog.takuros.net/entry/2014/05/17/172257
|
117
230
|
上記の記事を参考にしたところ、記事通りの挙動はしましたが結果は変わらずでした
|
231
|
+
```
|
232
|
+
$ wget http://curl.haxx.se/ca/cacert.pem
|
233
|
+
```
|
234
|
+
上記のコマンドで一応SSL証明書は手に入れた、、??
|
118
235
|
|
236
|
+
https://stackoverflow.com/questions/4528101/ssl-connect-returned-1-errno-0-state-sslv3-read-server-certificate-b-certificat
|
237
|
+
上記の記事を参考にしたところ
|
238
|
+
```
|
239
|
+
SSL_CERT_FILE=/opt/local/etc/certs/cacert.pem rails generate jquery:install
|
240
|
+
```
|
241
|
+
を実行したら
|
242
|
+
```
|
243
|
+
Running via Spring preloader in process 3195
|
244
|
+
Could not find generator 'jquery:install'.
|
245
|
+
Run `rails generate --help` for more options.
|
246
|
+
```
|
247
|
+
|
248
|
+
と出てきました、、
|
119
249
|
### 補足情報(FW/ツールのバージョンなど)
|
120
250
|
cloud9 ubunts
|
121
251
|
ruby 2.6.3
|