質問編集履歴

1

change

2017/08/10 12:21

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -6,56 +6,6 @@
6
6
 
7
7
 
8
8
 
9
- **users_controller.rb**
10
-
11
- ```Ruby
12
-
13
- def update
14
-
15
- @user = User.find_by(id: params[:id])
16
-
17
- @user.name = params[:name]
18
-
19
- @user.email = params[:email]
20
-
21
- @user.phone_number = params[:phone_number]
22
-
23
- @user.description = params[:description]
24
-
25
- @user.college_name = params[:college_name]
26
-
27
- //ここで、S3の方に、画像をアップデートをし、ユーザーの画像を表示させたいのです
28
-
29
- if params[:image]
30
-
31
- @user.image = "#{@user.id}.jpg"
32
-
33
- image = params[:image]
34
-
35
- File.binwrite("public/user_images/#{@user.image}", image.read)
36
-
37
- end
38
-
39
-
40
-
41
- if @user.save
42
-
43
- flash[:notice] = "ユーザー情報を編集しました"
44
-
45
- redirect_to("/users/#{@user.id}")
46
-
47
- else
48
-
49
- flash[:notice] = "ユーザー情報を更新できませんでした"
50
-
51
- render :edit
52
-
53
- end
54
-
55
- end
56
-
57
- ```
58
-
59
9
 
60
10
 
61
11
  現在は、S3の方に、保存できていない為か、表示されていません!