質問編集履歴

3

追記

2015/06/23 11:20

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -46,86 +46,48 @@
46
46
 
47
47
 
48
48
 
49
- ```lang-<ruby>
50
49
 
51
50
 
52
51
 
53
- 2015-06-21T04:57:50.122039+00:00 app[web.1]: Started GET "/categories/4/sub_categories" for 221.133.90.90 at 2015-06-21 04:57:50 +0000
54
52
 
55
- 2015-06-21T04:58:57.552332+00:00 app[web.1]: Started POST "/items" for 221.133.90.90 at 2015-06-21 04:58:57 +0000
53
+ PictureUploaderを下記に変更
56
54
 
57
- 2015-06-21T04:58:57.560891+00:00 app[web.1]: Category Load (0.5ms) SELECT "categories".* FROM "categories" WHERE "categories"."name" = $1 LIMIT 1 [["name", "root"]]
55
+ ```lang-<ruby
58
56
 
59
- 2015-06-21T04:58:57.554902+00:00 app[web.1]: Processing by ItemsController#create as HTML
57
+ def filename
60
58
 
61
- 2015-06-21T04:58:57.555006+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"GlkuJs8kRutr7DkJNTIXZGltATv16Z7SlduPQUcu81EEhFQzRqRss7/6sJ2Py4F/bOFRy77kDSZhI6T8gGSfUQ==", "item"=>{"category_id"=>"4", "sub_category_id"=>"46", "picture_1"=>#<ActionDispatch::Http::UploadedFile:0x007fdea5c33c88 @tempfile=#<Tempfile:/tmp/RackMultipart20150621-3-1pvqgj7.jpg>, @original_filename="image.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"item[picture_1]\"; filename=\"image.jpg\"\r\nContent-Type: image/jpeg\r\n">, "picture_1_cache"=>"", "picture_2_cache"=>"", "picture_3_cache"=>"", "picture_4_cache"=>"", "title"=>"66666666666", "content"=>"っっっっっっっっっっっg", "condition_id"=>"1", "delivery"=>"false", "area"=>"1", "limit_day"=>"2015-06-27 13:58"}, "commit"=>"出品する"}
59
+ "#{secure_token}.png" if original_filename.present?
62
60
 
63
- 2015-06-21T04:58:57.558263+00:00 app[web.1]: User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
64
-
65
- 2015-06-21T04:58:58.593921+00:00 app[web.1]: (0.7ms) BEGIN
66
-
67
- 2015-06-21T04:58:58.608082+00:00 app[web.1]: SQL (1.6ms) INSERT INTO "warrants" ("holder_id", "item_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["holder_id", 1], ["item_id", 11], ["created_at", "2015-06-21 04:58:58.604974"], ["updated_at", "2015-06-21 04:58:58.604974"]]
68
-
69
- 2015-06-21T04:58:58.603937+00:00 app[web.1]: SQL (0.9ms) INSERT INTO "items" ("title", "condition_id", "content", "area", "limit_day", "delivery", "category_id", "sub_category_id", "picture_1", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING "id" [["title", "66666666666"], ["condition_id", 1], ["content", "っっっっっっっっっっっg"], ["area", 1], ["limit_day", "2015-06-27 04:58:00.000000"], ["delivery", "f"], ["category_id", 4], ["sub_category_id", 46], ["picture_1", "image.jpg"], ["user_id", 1], ["created_at", "2015-06-21 04:58:58.597097"], ["updated_at", "2015-06-21 04:58:58.597097"]]
70
-
71
- 2015-06-21T04:59:01.528032+00:00 heroku[router]: at=info method=POST path="/items" host=ponta.herokuapp.com request_id=d8599bc7-e1fb-4aeb-a9f2-9cb6a151db14 fwd="221.133.90.90" dyno=web.1 connect=2ms service=5249ms status=302 bytes=1339
72
-
73
- 2015-06-21T04:59:01.513588+00:00 app[web.1]: (1.4ms) COMMIT
74
-
75
- 2015-06-21T04:59:01.518359+00:00 app[web.1]: Redirected to https://ponta.herokuapp.com/items/continue
76
-
77
- 2015-06-21T04:59:01.516213+00:00 app[web.1]: User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = $1 LIMIT 1 [["id", 1]]
78
-
79
- 2015-06-21T04:59:01.519916+00:00 app[web.1]: Completed 302 Found in 3965ms (ActiveRecord: 6.6ms)
80
-
81
- 2015-06-21T04:59:01.884980+00:00 app[web.1]: Started GET "/items/continue" for 221.133.90.90 at 2015-06-21 04:59:01 +0000
82
-
83
- 2015-06-21T04:59:01.894359+00:00 app[web.1]: User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
84
-
85
- 2015-06-21T04:59:01.902755+00:00 app[web.1]: Rendered items/continue.html.erb within layouts/application (1.4ms)
86
-
87
- 2015-06-21T04:59:01.917097+00:00 app[web.1]: Notification Load (0.7ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."recipient_id" = 1 AND "notifications"."status" = 'f'
88
-
89
- 2015-06-21T04:59:01.928591+00:00 app[web.1]: Profile Load (0.6ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = $1 LIMIT 1 [["user_id", 1]]
90
-
91
- 2015-06-21T04:59:01.933674+00:00 app[web.1]: Completed 200 OK in 44ms (Views: 29.8ms | ActiveRecord: 5.3ms)
92
-
93
- 2015-06-21T04:59:01.889764+00:00 app[web.1]: Processing by ItemsController#continue as HTML
94
-
95
- 2015-06-21T04:59:01.899011+00:00 app[web.1]: Category Load (0.9ms) SELECT "categories".* FROM "categories" WHERE "categories"."name" = $1 LIMIT 1 [["name", "root"]]
96
-
97
- 2015-06-21T04:59:01.913214+00:00 app[web.1]: Todo Load (1.6ms) SELECT "todos".* FROM "todos" WHERE ((exhibitor_id = 1 AND status = 'f') OR (proprietor_id = 1 AND status = 'f'))
98
-
99
- 2015-06-21T04:59:01.921099+00:00 app[web.1]: Category Load (0.7ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = $1 [["parent_id", 1]]
100
-
101
- 2015-06-21T04:59:01.933021+00:00 app[web.1]: Rendered ideas/_form.html.erb (2.1ms)
102
-
103
- 2015-06-21T04:59:01.944598+00:00 heroku[router]: at=info method=GET path="/items/continue" host=ponta.herokuapp.com request_id=5bf129f9-f189-4bca-a3b4-9e8472783cb4 fwd="221.133.90.90" dyno=web.1 connect=1ms service=66ms status=200 bytes=13488
104
-
105
- 2015-06-21T04:59:02.603671+00:00 heroku[router]: at=info method=GET path="/assets/opps.jpg" host=ponta.herokuapp.com request_id=9a5516b9-9af0-4988-b3da-3b5e260643d8 fwd="221.133.90.90" dyno=web.1 connect=9ms service=19ms status=304 bytes=343
106
-
107
- 2015-06-21T04:59:02.589854+00:00 app[web.1]: Started GET "/assets/opps.jpg" for 221.133.90.90 at 2015-06-21 04:59:02 +0000
108
-
109
- 2015-06-21T04:59:03.437611+00:00 app[web.1]: Started GET "/assets/lato/lato-regular.woff" for 221.133.90.90 at 2015-06-21 04:59:03 +0000
110
-
111
- 2015-06-21T04:59:03.447752+00:00 heroku[router]: at=info method=GET path="/assets/lato/lato-regular.woff" host=ponta.herokuapp.com request_id=b99c9f00-22e5-40f7-a197-f4beefcf32e5 fwd="221.133.90.90" dyno=web.1 connect=2ms service=11ms status=304 bytes=343
112
-
113
- 2015-06-21T04:59:03.900702+00:00 heroku[router]: at=info method=GET path="/assets/lato/lato-light.woff" host=ponta.herokuapp.com request_id=3085f989-4737-4631-a8a6-978283a762ef fwd="221.133.90.90" dyno=web.1 connect=9ms service=15ms status=304 bytes=343
114
-
115
- 2015-06-21T04:59:03.898327+00:00 heroku[router]: at=info method=GET path="/assets/lato/lato-bold.woff" host=ponta.herokuapp.com request_id=83fb3a02-f42b-4b64-a03e-ed71e93d551b fwd="221.133.90.90" dyno=web.1 connect=2ms service=6ms status=304 bytes=343
116
-
117
- 2015-06-21T04:59:03.909771+00:00 heroku[router]: at=info method=GET path="/assets/lato/lato-black.woff" host=ponta.herokuapp.com request_id=f3a1b687-ba75-4ff3-a48c-f16be0bab00e fwd="221.133.90.90" dyno=web.1 connect=2ms service=7ms status=304 bytes=343
118
-
119
- 2015-06-21T04:59:03.885385+00:00 app[web.1]: Started GET "/assets/lato/lato-light.woff" for 221.133.90.90 at 2015-06-21 04:59:03 +0000
120
-
121
- 2015-06-21T04:59:03.903886+00:00 app[web.1]: Started GET "/assets/lato/lato-black.woff" for 221.133.90.90 at 2015-06-21 04:59:03 +0000
122
-
123
- 2015-06-21T04:59:03.892069+00:00 app[web.1]: Started GET "/assets/lato/lato-bold.woff" for 221.133.90.90 at 2015-06-21 04:59:03 +0000
124
-
125
- 2015-06-21T04:59:03.915291+00:00 app[web.1]: Started GET "/assets/glyphicons/flat-ui-icons-regular.woff" for 221.133.90.90 at 2015-06-21 04:59:03 +0000
126
-
127
- 2015-06-21T04:59:03.922423+00:00 heroku[router]: at=info method=GET path="/assets/glyphicons/flat-ui-icons-regular.woff" host=ponta.herokuapp.com request_id=bc4e264a-79e8-45a5-8031-7ec6f48c42f5 fwd="221.133.90.90" dyno=web.1 connect=1ms service=6ms status=304 bytes=343
61
+ end
128
62
 
129
63
 
130
64
 
65
+ protected
66
+
67
+ def secure_token
68
+
69
+ var = :"@#{mounted_as}_secure_token"
70
+
71
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
72
+
73
+ end
74
+
131
75
  ```
76
+
77
+
78
+
79
+
80
+
81
+ 以前のコード
82
+
83
+
84
+
85
+ ```lang-<ruby>
86
+
87
+ def filename
88
+
89
+ "#{Time.now.strftime('%Y%m%d%H%M%S')}.jpg"
90
+
91
+ end
92
+
93
+ ```

2

追記

2015/06/23 11:20

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Rails4.2 iPhoneのsafariから更新すると全てのアイテムが更新されてしまう
1
+ Rails4.2 iPhoneのブラウザから更新すると全てのアイテムが更新されてしまう
test CHANGED
@@ -1,10 +1,14 @@
1
- herokuにアプリをアップしました。
1
+ herokuにアプリをアップしました。
2
2
 
3
- macbookからテストした時は問題なかったのですが、iPhonesafariでのテスト下記の問題が起きました。
3
+ macbookのsafariからテストした時は問題なかったのですが、iPhoneからsafariとchromeテストした際に下記の問題が起きました。
4
4
 
5
5
 
6
6
 
7
- Item modelでitemをcreateするとユーザが過去にcreateした全てのアイテムの画像(picture_1)が更新され、新規でcreateしたものに差し代わってしま
7
+ Item modelでitemをcreateするとユーザが過去にcreateした全てのアイテムの画像(picture_1のみ)が更新されてしまいます
8
+
9
+ 新規でcreateしたitem自体はpicture_1とpicture_2が両方ともpicture_2の画像にに差し代わってしまいます。
10
+
11
+
8
12
 
9
13
  原因が全くわかりません
10
14
 

1

つい

2015/06/23 05:01

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Item modelでitemをcreateするとユーザが過去にcreateした全てのアイテムの画像(picture_1)が更新され、新規でcreateしたものに差し代わってしまう。
8
8
 
9
-
9
+ 原因が全くわかりません
10
10
 
11
11
 
12
12