質問編集履歴
2
storage.ymlを追記致しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,28 +78,12 @@
|
|
78
78
|
render :edit
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
82
|
-
def search
|
83
|
-
@results = @q.result
|
84
|
-
|
81
|
+
~~~
|
85
|
-
|
86
82
|
private
|
87
83
|
def item_params
|
88
84
|
params.require(:item).permit(:image, :name, :content, :code, :category_id, :cost, :price, :price_unit, :order_unit, :quantity, :order_lot, :eat_time)
|
89
85
|
end
|
90
|
-
|
91
|
-
def user_find
|
92
|
-
if user_signed_in?
|
93
|
-
@user = User.find(params[:current_user_id])
|
94
|
-
else
|
95
|
-
@admin = Admin.find(params[:admin_id])
|
96
|
-
|
86
|
+
~~~
|
97
|
-
end
|
98
|
-
|
99
|
-
def set_q
|
100
|
-
@q = Item.ransack(params[:q])
|
101
|
-
end
|
102
|
-
|
103
87
|
end
|
104
88
|
```
|
105
89
|
|
@@ -242,6 +226,42 @@
|
|
242
226
|
belongs_to :order
|
243
227
|
end
|
244
228
|
```
|
229
|
+
```storage.yml
|
230
|
+
test:
|
231
|
+
service: Disk
|
232
|
+
root: <%= Rails.root.join("tmp/storage") %>
|
233
|
+
|
234
|
+
local:
|
235
|
+
service: Disk
|
236
|
+
root: <%= Rails.root.join("storage") %>
|
237
|
+
|
238
|
+
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
239
|
+
# amazon:
|
240
|
+
# service: S3
|
241
|
+
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
242
|
+
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
243
|
+
# region: us-east-1
|
244
|
+
# bucket: your_own_bucket
|
245
|
+
|
246
|
+
# Remember not to checkin your GCS keyfile to a repository
|
247
|
+
# google:
|
248
|
+
# service: GCS
|
249
|
+
# project: your_project
|
250
|
+
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
251
|
+
# bucket: your_own_bucket
|
252
|
+
|
253
|
+
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
254
|
+
# microsoft:
|
255
|
+
# service: AzureStorage
|
256
|
+
# storage_account_name: your_account_name
|
257
|
+
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
258
|
+
# container: your_container_name
|
259
|
+
|
260
|
+
# mirror:
|
261
|
+
# service: Mirror
|
262
|
+
# primary: local
|
263
|
+
# mirrors: [ amazon, google, microsoft ]
|
264
|
+
```
|
245
265
|
|
246
266
|
### 試したこと・調べたこと
|
247
267
|
- [ ] teratailやGoogle等で検索した
|
1
item.rb/modelsとターミナルでのエラーメッセージを追記致しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,30 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
GET http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBZ3ciLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--9927478003bae35be9d79068d20356911a84fd72/bakedcheesecake.jpg 404 (Not Found)
|
13
|
+
```
|
14
|
+
```error
|
15
|
+
Started PATCH "/items/5" for ::1 at 2024-05-05 17:50:34 +0900
|
16
|
+
Processing by ItemsController#update as HTML
|
17
|
+
Parameters: {"authenticity_token"=>"UmC25Xnh+x/1AceM4RYlShbLnCuTIH5irXTH/CJ/cQ/aiOrnJjypcxfKio5YVi+R3iiXb/zSUs+sZM7YEiaQbQ==", "item"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x00007fce879f7358 @tempfile=#<Tempfile:/var/folders/lz/gh5tmw3x3wx3g7xrsxqsfj4r0000gn/T/RackMultipart20240505-4029-2bc7ad.jpg>, @original_filename="bakedcheesecake.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"item[image]\"; filename=\"bakedcheesecake.jpg\"\r\nContent-Type: image/jpeg\r\n">, "name"=>"ベイクドチーズケーキ", "content"=>"国産素材を使用したチーズケーキです。", "code"=>"222", "category_id"=>"7", "cost"=>"900", "price"=>"1300", "price_unit"=>"箱", "order_unit"=>"1", "quantity"=>"12", "order_lot"=>"1", "eat_time"=>"90"}, "commit"=>"登録する", "id"=>"5"}
|
18
|
+
Item Load (0.7ms) SELECT `items`.* FROM `items` WHERE `items`.`id` = 5 LIMIT 1
|
19
|
+
↳ app/controllers/items_controller.rb:33:in `update'
|
20
|
+
Rendering items/edit.html.erb within layouts/application
|
21
|
+
Admin Load (0.7ms) SELECT `admins`.* FROM `admins` WHERE `admins`.`id` = 6 ORDER BY `admins`.`id` ASC LIMIT 1
|
22
|
+
↳ app/views/shared/_header.html.erb:10
|
23
|
+
Rendered shared/_header.html.erb (Duration: 6.5ms | Allocations: 1811)
|
24
|
+
ActiveStorage::Blob Load (0.7ms) SELECT `active_storage_blobs`.* FROM `active_storage_blobs` INNER JOIN `active_storage_attachments` ON `active_storage_blobs`.`id` = `active_storage_attachments`.`blob_id` WHERE `active_storage_attachments`.`record_id` = 5 AND `active_storage_attachments`.`record_type` = 'Item' AND `active_storage_attachments`.`name` = 'image' LIMIT 1
|
25
|
+
↳ app/views/items/_form.html.erb:12
|
26
|
+
Rendered items/_form.html.erb (Duration: 12.4ms | Allocations: 3468)
|
27
|
+
Rendered items/edit.html.erb within layouts/application (Duration: 19.9ms | Allocations: 5421)
|
28
|
+
[Webpacker] Everything's up-to-date. Nothing to do
|
29
|
+
Completed 200 OK in 38ms (Views: 29.9ms | ActiveRecord: 2.2ms | Allocations: 12162)
|
30
|
+
|
31
|
+
|
32
|
+
Started GET "/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBZ3ciLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--9927478003bae35be9d79068d20356911a84fd72/bakedcheesecake.jpg" for ::1 at 2024-05-05 17:50:34 +0900
|
33
|
+
Processing by ActiveStorage::BlobsController#show as JPEG
|
34
|
+
Parameters: {"signed_id"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBZ3ciLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--9927478003bae35be9d79068d20356911a84fd72", "filename"=>"bakedcheesecake"}
|
35
|
+
Filter chain halted as :set_blob rendered or redirected
|
36
|
+
Completed 404 Not Found in 2ms (ActiveRecord: 0.0ms | Allocations: 711)
|
13
37
|
```
|
14
38
|
|
15
39
|
### 該当のソースコード
|
@@ -204,6 +228,20 @@
|
|
204
228
|
</div>
|
205
229
|
<% end %>
|
206
230
|
```
|
231
|
+
```item.rb/models
|
232
|
+
class Item < ApplicationRecord
|
233
|
+
extend ActiveHash::Associations::ActiveRecordExtensions
|
234
|
+
belongs_to :category
|
235
|
+
has_one_attached :image
|
236
|
+
has_many :users, through: :item_users
|
237
|
+
has_many :item_users
|
238
|
+
has_many :admins, through: :item_admins
|
239
|
+
has_many :item_admins
|
240
|
+
has_many :stocks
|
241
|
+
has_many :favorites, dependent: :destroy
|
242
|
+
belongs_to :order
|
243
|
+
end
|
244
|
+
```
|
207
245
|
|
208
246
|
### 試したこと・調べたこと
|
209
247
|
- [ ] teratailやGoogle等で検索した
|