質問編集履歴

9

cat log/production.log追記内容変更

2020/04/24 08:20

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -140,19 +140,17 @@
140
140
 
141
141
  [cat production.log]
142
142
 
143
- <ActionDispatch::Http::UploadedFile:0x0000000004e92150 @tempfile=#<Tempfile:/tmp/RackMultipart20200423-26309-1r14tu.jpg>, @original_filename="aritokirigirisu.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"aritokirigirisu.jpg\"\r\nContent-Type: image/jpeg\r\n">, "image_cache"=>"", "pharse"=>"test。", "summery"=>"test"}, "commit"=>"投稿する"}
144
-
145
- D, [2020-04-23T00:39:24.642050 #26309] DEBUG -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
146
-
147
- I, [2020-04-23T00:39:25.014269 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Completed 500 Internal Server Error in 374ms (ActiveRecord: 0.3ms)
148
-
149
- F, [2020-04-23T00:39:25.015082 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f]
150
-
151
- F, [2020-04-23T00:39:25.015127 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] ActiveModel::UnknownAttributeError (unknown attribute 'user_id' for Post.):
152
-
153
- F, [2020-04-23T00:39:25.015161 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f]
154
-
155
- F, [2020-04-23T00:39:25.015199 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] app/controllers/posts_controller.rb:15:in `create'
143
+ D, [2020-04-24T07:59:26.562168 #8911] DEBUG -- : [a457333a-4c4b-4770-96b6-41913fda344a] User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
144
+
145
+ I, [2020-04-24T07:59:26.902848 #8911] INFO -- : [a457333a-4c4b-4770-96b6-41913fda344a] Completed 500 Internal Server Error in 342ms (ActiveRecord: 0.3ms)
146
+
147
+ F, [2020-04-24T07:59:26.903563 #8911] FATAL -- : [a457333a-4c4b-4770-96b6-41913fda344a]
148
+
149
+ F, [2020-04-24T07:59:26.903604 #8911] FATAL -- : [a457333a-4c4b-4770-96b6-41913fda344a] ActiveModel::UnknownAttributeError (unknown attribute 'user_id' for Post.):
150
+
151
+ F, [2020-04-24T07:59:26.903674 #8911] FATAL -- : [a457333a-4c4b-4770-96b6-41913fda344a]
152
+
153
+ F, [2020-04-24T07:59:26.903721 #8911] FATAL -- : [a457333a-4c4b-4770-96b6-41913fda344a] app/controllers/posts_controller.rb:15:in `create'
156
154
 
157
155
  ```
158
156
 

8

postモデル追記

2020/04/24 08:20

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -383,3 +383,121 @@
383
383
  =render partial: "footer"
384
384
 
385
385
  ```
386
+
387
+ ```
388
+
389
+ [post.rb]
390
+
391
+ class Post < ApplicationRecord
392
+
393
+ has_many :comments
394
+
395
+ has_many :likes
396
+
397
+ belongs_to :user
398
+
399
+
400
+
401
+ validates :title, {presence: true, length: {maximum: 25}}
402
+
403
+ validates :image, :category_id, presence: true
404
+
405
+ validates :pharse, {presence: true, length: {maximum: 25}}
406
+
407
+ validates :summery, {presence: true, length: {maximum: 100}}
408
+
409
+ mount_uploader :image, ImageUploader
410
+
411
+ end
412
+
413
+ ```
414
+
415
+ ```
416
+
417
+ [schema.rb]
418
+
419
+ ActiveRecord::Schema.define(version: 2020_04_10_005746) do
420
+
421
+
422
+
423
+ create_table "posts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
424
+
425
+ t.string "title", null: false
426
+
427
+ t.string "pharse", null: false
428
+
429
+ t.text "summery", null: false
430
+
431
+ t.datetime "created_at", null: false
432
+
433
+ t.datetime "updated_at", null: false
434
+
435
+ t.text "image", null: false
436
+
437
+ t.integer "category_id", null: false
438
+
439
+ t.integer "user_id"
440
+
441
+ end
442
+
443
+
444
+
445
+ create_table "user_informations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
446
+
447
+ t.bigint "user_id"
448
+
449
+ t.integer "prefecture_id", default: 0, null: false
450
+
451
+ t.string "city", null: false
452
+
453
+ t.integer "birth_year", null: false
454
+
455
+ t.integer "birth_month", null: false
456
+
457
+ t.integer "birth_day", null: false
458
+
459
+ t.integer "age_id", null: false
460
+
461
+ t.integer "gender_id", null: false
462
+
463
+ t.datetime "created_at", null: false
464
+
465
+ t.datetime "updated_at", null: false
466
+
467
+ t.index ["user_id"], name: "index_user_informations_on_user_id"
468
+
469
+ end
470
+
471
+
472
+
473
+ create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
474
+
475
+ t.string "nickname", null: false
476
+
477
+ t.string "email", default: "", null: false
478
+
479
+ t.string "encrypted_password", default: "", null: false
480
+
481
+ t.string "reset_password_token"
482
+
483
+ t.datetime "reset_password_sent_at"
484
+
485
+ t.datetime "remember_created_at"
486
+
487
+ t.datetime "created_at", null: false
488
+
489
+ t.datetime "updated_at", null: false
490
+
491
+ t.index ["email"], name: "index_users_on_email", unique: true
492
+
493
+ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
494
+
495
+ end
496
+
497
+
498
+
499
+ add_foreign_key "user_informations", "users"
500
+
501
+ end
502
+
503
+ ```

7

controllerコード追記

2020/04/23 08:24

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -140,35 +140,7 @@
140
140
 
141
141
  [cat production.log]
142
142
 
143
-
144
-
145
- I, [2020-04-23T00:38:54.623549 #26309] INFO -- : [dd481177-999a-4e7f-adbe-04810af52f27] Rendered posts/_footer.html.haml (2.8ms)
146
-
147
- I, [2020-04-23T00:38:54.623724 #26309] INFO -- : [dd481177-999a-4e7f-adbe-04810af52f27] Rendered posts/index.html.haml within layouts/application (43.1ms)
148
-
149
- I, [2020-04-23T00:38:54.628055 #26309] INFO -- : [dd481177-999a-4e7f-adbe-04810af52f27] Completed 200 OK in 52ms (Views: 50.1ms | ActiveRecord: 2.4ms)
150
-
151
- I, [2020-04-23T00:39:00.852388 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Started GET "/posts/new" for 133.106.68.214 at 2020-04-23 00:39:00 +0000
152
-
153
- I, [2020-04-23T00:39:00.853379 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Processing by PostsController#new as HTML
154
-
155
- D, [2020-04-23T00:39:00.854838 #26309] DEBUG -- : [1801f192-e431-45a4-9f8d-bee275b3711a] User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
156
-
157
- I, [2020-04-23T00:39:00.864400 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendering posts/new.html.haml within layouts/application
158
-
159
- I, [2020-04-23T00:39:00.875411 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendered posts/_header.html.haml (3.2ms)
160
-
161
- I, [2020-04-23T00:39:00.878642 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendered posts/_footer.html.haml (0.2ms)
162
-
163
- I, [2020-04-23T00:39:00.878714 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendered posts/new.html.haml within layouts/application (14.2ms)
164
-
165
- I, [2020-04-23T00:39:00.879244 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Completed 200 OK in 26ms (Views: 15.1ms | ActiveRecord: 0.5ms)
166
-
167
- I, [2020-04-23T00:39:24.639458 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Started POST "/posts" for 133.106.68.214 at 2020-04-23 00:39:24 +0000
168
-
169
- I, [2020-04-23T00:39:24.640255 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Processing by PostsController#create as HTML
170
-
171
- I, [2020-04-23T00:39:24.640386 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Parameters: {"utf8"=>"✓", "authenticity_token"=>"GmELWkFWxby+Rn3zUCZS8qaj3ngS71tasI4MXOPsVm4iBik/hgLseyQqSyC9Wd/syC9Gzf096ymwniBnJYGbHQ==", "post"=>{"title"=>"test", "category_id"=>"1", "image"=>#<ActionDispatch::Http::UploadedFile:0x0000000004e92150 @tempfile=#<Tempfile:/tmp/RackMultipart20200423-26309-1r14tu.jpg>, @original_filename="aritokirigirisu.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"aritokirigirisu.jpg\"\r\nContent-Type: image/jpeg\r\n">, "image_cache"=>"", "pharse"=>"test。", "summery"=>"test"}, "commit"=>"投稿する"}
143
+ <ActionDispatch::Http::UploadedFile:0x0000000004e92150 @tempfile=#<Tempfile:/tmp/RackMultipart20200423-26309-1r14tu.jpg>, @original_filename="aritokirigirisu.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"aritokirigirisu.jpg\"\r\nContent-Type: image/jpeg\r\n">, "image_cache"=>"", "pharse"=>"test。", "summery"=>"test"}, "commit"=>"投稿する"}
172
144
 
173
145
  D, [2020-04-23T00:39:24.642050 #26309] DEBUG -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
174
146
 
@@ -182,12 +154,232 @@
182
154
 
183
155
  F, [2020-04-23T00:39:25.015199 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] app/controllers/posts_controller.rb:15:in `create'
184
156
 
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
- ```
157
+ ```
158
+
159
+ ```
160
+
161
+ [posts_controller]
162
+
163
+ class PostsController < ApplicationController
164
+
165
+ before_action :move_to_index, except: [:index, :show]
166
+
167
+ before_action :set_post, only: [:show, :destroy, :edit, :update]
168
+
169
+
170
+
171
+ def index
172
+
173
+ @posts = Post.all.limit(5).order("created_at DESC")
174
+
175
+ end
176
+
177
+
178
+
179
+ def new
180
+
181
+ @post = Post.new
182
+
183
+ end
184
+
185
+
186
+
187
+ def create
188
+
189
+ @post = Post.new(post_params)
190
+
191
+ if @post.save
192
+
193
+ redirect_to root_path
194
+
195
+ else
196
+
197
+ render :new
198
+
199
+ end
200
+
201
+ end
202
+
203
+
204
+
205
+ def show
206
+
207
+ end
208
+
209
+
210
+
211
+ def destroy
212
+
213
+ if @post.destroy
214
+
215
+ redirect_to root_path
216
+
217
+ else
218
+
219
+ render post_path(post.user_id,post.id)
220
+
221
+ end
222
+
223
+ end
224
+
225
+
226
+
227
+ def edit
228
+
229
+ end
230
+
231
+
232
+
233
+ def update
234
+
235
+ if @post.update(post_update_params)
236
+
237
+ redirect_to post_path(@post)
238
+
239
+ else
240
+
241
+ render :edit
242
+
243
+ end
244
+
245
+ end
246
+
247
+
248
+
249
+ def post_params
250
+
251
+ params.require(:post).permit(
252
+
253
+ :title, :category_id, :image, :pharse, :summery).merge(user_id: current_user.id)
254
+
255
+ end
256
+
257
+
258
+
259
+ def post_update_params
260
+
261
+ params.require(:post).permit(
262
+
263
+ :title, :category_id, :image, :image_cache ,:remove_image, :pharse, :summery).merge(user_id: current_user.id)
264
+
265
+ end
266
+
267
+
268
+
269
+ def move_to_index
270
+
271
+ redirect_to root_path unless user_signed_in?
272
+
273
+ end
274
+
275
+
276
+
277
+ def set_post
278
+
279
+ @post = Post.find(params[:id])
280
+
281
+ end
282
+
283
+ end
284
+
285
+ ```
286
+
287
+ ```
288
+
289
+ [new.html.haml]
290
+
291
+ =render partial: "header"
292
+
293
+
294
+
295
+ .post__container
296
+
297
+ .post__container__content
298
+
299
+ .post__container__content__text
300
+
301
+ %h1 テキスト
302
+
303
+ .post__container__content__input
304
+
305
+ =form_with(model: @post, local:true) do |f|
306
+
307
+ .post__container__content__input__form
308
+
309
+ .title
310
+
311
+ = f.label :title, "テキスト", class: 'input-content'
312
+
313
+ %span.form-require
314
+
315
+ テキスト
316
+
317
+ %br/
318
+
319
+ = f.text_field :title, autofocus: true, placeholder: "テキスト", class: 'content-default', id: "src_img"
320
+
321
+ .category
322
+
323
+ = f.label :category_id, "カテゴリー", class: 'input-content'
324
+
325
+ %span.form-require
326
+
327
+ テキスト
328
+
329
+ %br/
330
+
331
+ =f.collection_select :category_id, Category.all,:id,:name, {prompt: '選択してください'}, class: 'content-default'
332
+
333
+ .image
334
+
335
+ = f.label :image, "テキスト", class: 'input-content'
336
+
337
+ %span.form-require
338
+
339
+ テキスト
340
+
341
+ %br/
342
+
343
+ #img_field{onclick: "$('#file').click()"}
344
+
345
+ %label.image_input_btn
346
+
347
+ テキスト
348
+
349
+ = f.file_field :image, autofocus: true, class: 'content-image', id: 'file'
350
+
351
+ = f.hidden_field :image_cache, class: 'hidden'
352
+
353
+ .pharse
354
+
355
+ = f.label :pharse, "テキスト", class: 'input-content', size: 25
356
+
357
+ %span.form-require
358
+
359
+ テキスト
360
+
361
+ %br/
362
+
363
+ = f.text_field :pharse, autofocus: true, placeholder: テキスト", class: 'content-default'
364
+
365
+ .summery
366
+
367
+ = f.label :summery, "テキスト", class: 'input-content'
368
+
369
+ %span.form-require
370
+
371
+ テキスト
372
+
373
+ %br/
374
+
375
+ = f.text_area :summery, autofocus: true, placeholder: "テキスト", class: 'content-summery'
376
+
377
+ .post-btn
378
+
379
+ = f.submit '投稿する', {class: 'btn-red'}
380
+
381
+
382
+
383
+ =render partial: "footer"
384
+
385
+ ```

6

cat production.log追記

2020/04/23 05:44

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -80,22 +80,6 @@
80
80
 
81
81
 
82
82
 
83
-  
84
-
85
- * ```cat log/production.log```の確認
86
-
87
- ```
88
-
89
- ActionController::RoutingError (No route matches [GET] "/images/create.jpg"):
90
-
91
- ```
92
-
93
- と記載されていたが、route.rbのどこをいじればよいか
94
-
95
- 正直理解が足りず、ここに関しては何もできていない状態です。
96
-
97
-
98
-
99
83
  # コード
100
84
 
101
85
  ```
@@ -148,272 +132,62 @@
148
132
 
149
133
  ```
150
134
 
151
- ```
152
-
153
- [deploy.rb]
154
-
155
- #Capistranoのバージョンを固定
156
-
157
- lock '3.13.0'
158
-
159
- # Capistranoのログの表示に利用する
160
-
161
- set :application, 'application_name'
162
-
163
-
164
-
165
- # どのリポジトリからアプリをpullするかを指定する
166
-
167
- set :repo_url, 'git@github.com:ユーザ名/アプリ名.git'
168
-
169
-
170
-
171
- # バージョンが変わっても共通で参照するディレクトリを指定
172
-
173
- set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
174
-
175
- set :linked_files, %w{config/master.key}
176
-
177
-
178
-
179
- # どの公開鍵を利用してデプロイするか
180
-
181
- set :ssh_options, auth_methods: ['publickey'],
182
-
183
- keys: ['~/.ssh/***.pem']
184
-
185
-
186
-
187
- # プロセス番号を記載したファイルの場所
188
-
189
- set :unicorn_pid, -> { "#{shared_path}/tmp/pids/unicorn.pid" }
190
-
191
-
192
-
193
- # Unicornの設定ファイルの場所
194
-
195
- set :unicorn_config_path, -> { "#{current_path}/config/unicorn.rb" }
196
-
197
- set :keep_releases, 5
198
-
199
-
200
-
201
- after 'deploy:publishing', 'deploy:restart'
202
-
203
- namespace :deploy do
204
-
205
- task :restart do
206
-
207
- invoke 'unicorn:restart'
208
-
209
- end
210
-
211
-
212
-
213
- desc 'upload master.key'
214
-
215
- task :upload do
216
-
217
- on roles(:app) do |host|
218
-
219
- if test "[ ! -d #{shared_path}/config ]"
220
-
221
- execute "mkdir -p #{shared_path}/config"
222
-
223
- end
224
-
225
- upload!('config/master.key', "#{shared_path}/config/master.key")
226
-
227
- end
228
-
229
- end
230
-
231
- before :starting, 'deploy:upload'
232
-
233
- after :finishing, 'deploy:cleanup'
234
-
235
- end
236
-
237
-
238
-
239
- set :default_env, {
240
-
241
- rbenv_root: "/usr/local/rbenv",
242
-
243
- path: "/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH",
244
-
245
- AWS_ACCESS_KEY_ID: ENV["AWS_ACCESS_KEY_ID"],
246
-
247
- AWS_SECRET_ACCESS_KEY: ENV["AWS_SECRET_ACCESS_KEY"]
248
-
249
- }
250
-
251
- ```
252
-
253
-
254
-
255
- # 参考にした資料
256
-
257
-
258
-
259
- [Ruby on Rails チュートリアル](https://railstutorial.jp/chapters/user_microposts?version=5.1#sec-image_upload_in_production)
260
-
261
- [【AWS】Railsで本番環境のみS3へ画像アップロードする分岐文【S3】](https://qiita.com/15grmr/items/71859caea0414f2e245d)
262
-
263
- [Rails5+CarrierWave+fog+Heroku+S3でデプロイした](https://qiita.com/tmyn470/items/6422052f28d2a10d73cc)
264
-
265
- [capistranoを使ったEC2へのデプロイまとめ](https://qiita.com/naginx/items/fe9f9cfe942d404aa8b8)
266
-
267
- ・・・etc
268
-
269
135
 
270
136
 
271
137
  # 追記
272
138
 
273
139
  ```
274
140
 
275
- [ log/production]
276
-
277
- [ec2-user@ip- app-name]$ tail -f log/production.log
278
-
279
- I, [2020-04-18T02:55:27.464624 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Started GET "/" for 133.106.86.67 at 2020-04-18 02:55:27 +0000
280
-
281
- I, [2020-04-18T02:55:27.467025 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Processing by PostsController#index as HTML
282
-
283
- I, [2020-04-18T02:55:27.471902 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Rendering posts/index.html.haml within layouts/application
284
-
285
- D, [2020-04-18T02:55:27.495308 #6785] DEBUG -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] (0.2ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
286
-
287
- D, [2020-04-18T02:55:27.496467 #6785] DEBUG -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Post Load (0.3ms) SELECT `posts`.* FROM `posts` ORDER BY created_at DESC LIMIT 5
288
-
289
- I, [2020-04-18T02:55:27.501122 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Rendered posts/_footer.html.haml (2.3ms)
290
-
291
- I, [2020-04-18T02:55:27.501316 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Rendered posts/index.html.haml within layouts/application (29.3ms)
292
-
293
- I, [2020-04-18T02:55:27.504913 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Completed 200 OK in 38ms (Views: 35.6ms | ActiveRecord: 1.0ms)
294
-
295
- D, [2020-04-20T14:50:37.925212 #4185] DEBUG -- : (5.1ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
296
-
297
- D, [2020-04-21T05:29:54.858295 #9546] DEBUG -- : (0.2ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
298
-
299
- ```
300
-
301
- ```
302
-
303
- [index.html.haml]
304
-
305
- %html
306
-
307
- %body
308
-
309
- .header
310
-
311
- .container
312
-
313
- %ul.header__box
314
-
315
- %li.header__box__left
316
-
317
- .header__box__left__appName
318
-
319
- =link_to "***", root_path, class: "appName"
320
-
321
- %li.header__box__right
322
-
323
- %ul
324
-
325
- - if user_signed_in?
326
-
327
- %li= link_to "ログアウト", destroy_user_session_path, method: :delete, class: "header__box__right__logBtn"
328
-
329
- %li= link_to "マイページ", user_path(current_user.id), class: "header__box__right__userBtn"
330
-
331
- - else
332
-
333
- %li= link_to "ログイン", new_user_session_path, class: "header__box__right__logBtn"
334
-
335
- %li= link_to "新規会員登録", new_user_registration_path, class: "header__box__right__userBtn"
336
-
337
-
338
-
339
- .main
340
-
341
- .main__first
342
-
343
- .main__first__content
344
-
345
- %h1.main__first__content__text
346
-
347
- テキスト
348
-
349
- .main__second
350
-
351
- .main__second__text
352
-
353
- %h2 テキスト
354
-
355
- .main__second__box
356
-
357
- .main__second__box__info
358
-
359
- =image_tag("/images/conclusion.jpg", width: "300", class: "main__secondImage")
360
-
361
- .main__second__box__info__number
362
-
363
- %h1 1
364
-
365
- %h3 テキスト
366
-
367
- %p テキスト
368
-
369
- .main__second__box__info
370
-
371
- =image_tag("/images/think2.jpg", width: "300", class: "main__secondImage")
372
-
373
- .main__second__box__info__number
374
-
375
- %h1 2
376
-
377
- %h3 テキスト
378
-
379
- %p テキスト
380
-
381
- .main__second__box__info
382
-
383
- =image_tag("/images/think.jpg", width: "300", class: "main__secondImage")
384
-
385
- .main__second__box__info__number
386
-
387
- %h1 3
388
-
389
- %h3 テキスト
390
-
391
- %p テキスト
392
-
393
- .post
394
-
395
- .post__text
396
-
397
- %h2 新着情報
398
-
399
- .post__container
400
-
401
- - @posts.each do |post|
402
-
403
- .post__container__infomation
404
-
405
- = link_to image_tag("#{post.image.url}", width: "80%", height: "250px"), post_path(post)
406
-
407
- .post__container__infomation__name
408
-
409
- = post.title
410
-
411
- = render partial: "footer"
141
+ [cat production.log]
412
142
 
413
143
 
414
144
 
415
- .icon
145
+ I, [2020-04-23T00:38:54.623549 #26309] INFO -- : [dd481177-999a-4e7f-adbe-04810af52f27] Rendered posts/_footer.html.haml (2.8ms)
416
146
 
417
- = link_to image_tag("/images/create.jpg", width: "120", height: "120"), new_post_path
147
+ I, [2020-04-23T00:38:54.623724 #26309] INFO -- : [dd481177-999a-4e7f-adbe-04810af52f27] Rendered posts/index.html.haml within layouts/application (43.1ms)
148
+
149
+ I, [2020-04-23T00:38:54.628055 #26309] INFO -- : [dd481177-999a-4e7f-adbe-04810af52f27] Completed 200 OK in 52ms (Views: 50.1ms | ActiveRecord: 2.4ms)
150
+
151
+ I, [2020-04-23T00:39:00.852388 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Started GET "/posts/new" for 133.106.68.214 at 2020-04-23 00:39:00 +0000
152
+
153
+ I, [2020-04-23T00:39:00.853379 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Processing by PostsController#new as HTML
154
+
155
+ D, [2020-04-23T00:39:00.854838 #26309] DEBUG -- : [1801f192-e431-45a4-9f8d-bee275b3711a] User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
156
+
157
+ I, [2020-04-23T00:39:00.864400 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendering posts/new.html.haml within layouts/application
158
+
159
+ I, [2020-04-23T00:39:00.875411 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendered posts/_header.html.haml (3.2ms)
160
+
161
+ I, [2020-04-23T00:39:00.878642 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendered posts/_footer.html.haml (0.2ms)
162
+
163
+ I, [2020-04-23T00:39:00.878714 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Rendered posts/new.html.haml within layouts/application (14.2ms)
164
+
165
+ I, [2020-04-23T00:39:00.879244 #26309] INFO -- : [1801f192-e431-45a4-9f8d-bee275b3711a] Completed 200 OK in 26ms (Views: 15.1ms | ActiveRecord: 0.5ms)
166
+
167
+ I, [2020-04-23T00:39:24.639458 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Started POST "/posts" for 133.106.68.214 at 2020-04-23 00:39:24 +0000
168
+
169
+ I, [2020-04-23T00:39:24.640255 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Processing by PostsController#create as HTML
170
+
171
+ I, [2020-04-23T00:39:24.640386 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Parameters: {"utf8"=>"✓", "authenticity_token"=>"GmELWkFWxby+Rn3zUCZS8qaj3ngS71tasI4MXOPsVm4iBik/hgLseyQqSyC9Wd/syC9Gzf096ymwniBnJYGbHQ==", "post"=>{"title"=>"test", "category_id"=>"1", "image"=>#<ActionDispatch::Http::UploadedFile:0x0000000004e92150 @tempfile=#<Tempfile:/tmp/RackMultipart20200423-26309-1r14tu.jpg>, @original_filename="aritokirigirisu.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"post[image]\"; filename=\"aritokirigirisu.jpg\"\r\nContent-Type: image/jpeg\r\n">, "image_cache"=>"", "pharse"=>"test。", "summery"=>"test"}, "commit"=>"投稿する"}
172
+
173
+ D, [2020-04-23T00:39:24.642050 #26309] DEBUG -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
174
+
175
+ I, [2020-04-23T00:39:25.014269 #26309] INFO -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] Completed 500 Internal Server Error in 374ms (ActiveRecord: 0.3ms)
176
+
177
+ F, [2020-04-23T00:39:25.015082 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f]
178
+
179
+ F, [2020-04-23T00:39:25.015127 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] ActiveModel::UnknownAttributeError (unknown attribute 'user_id' for Post.):
180
+
181
+ F, [2020-04-23T00:39:25.015161 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f]
182
+
183
+ F, [2020-04-23T00:39:25.015199 #26309] FATAL -- : [d7887b07-9422-4eb6-a3c0-8971dbd38e9f] app/controllers/posts_controller.rb:15:in `create'
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
418
192
 
419
193
  ```

5

indexのview追記

2020/04/23 00:56

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -297,3 +297,123 @@
297
297
  D, [2020-04-21T05:29:54.858295 #9546] DEBUG -- : (0.2ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
298
298
 
299
299
  ```
300
+
301
+ ```
302
+
303
+ [index.html.haml]
304
+
305
+ %html
306
+
307
+ %body
308
+
309
+ .header
310
+
311
+ .container
312
+
313
+ %ul.header__box
314
+
315
+ %li.header__box__left
316
+
317
+ .header__box__left__appName
318
+
319
+ =link_to "***", root_path, class: "appName"
320
+
321
+ %li.header__box__right
322
+
323
+ %ul
324
+
325
+ - if user_signed_in?
326
+
327
+ %li= link_to "ログアウト", destroy_user_session_path, method: :delete, class: "header__box__right__logBtn"
328
+
329
+ %li= link_to "マイページ", user_path(current_user.id), class: "header__box__right__userBtn"
330
+
331
+ - else
332
+
333
+ %li= link_to "ログイン", new_user_session_path, class: "header__box__right__logBtn"
334
+
335
+ %li= link_to "新規会員登録", new_user_registration_path, class: "header__box__right__userBtn"
336
+
337
+
338
+
339
+ .main
340
+
341
+ .main__first
342
+
343
+ .main__first__content
344
+
345
+ %h1.main__first__content__text
346
+
347
+ テキスト
348
+
349
+ .main__second
350
+
351
+ .main__second__text
352
+
353
+ %h2 テキスト
354
+
355
+ .main__second__box
356
+
357
+ .main__second__box__info
358
+
359
+ =image_tag("/images/conclusion.jpg", width: "300", class: "main__secondImage")
360
+
361
+ .main__second__box__info__number
362
+
363
+ %h1 1
364
+
365
+ %h3 テキスト
366
+
367
+ %p テキスト
368
+
369
+ .main__second__box__info
370
+
371
+ =image_tag("/images/think2.jpg", width: "300", class: "main__secondImage")
372
+
373
+ .main__second__box__info__number
374
+
375
+ %h1 2
376
+
377
+ %h3 テキスト
378
+
379
+ %p テキスト
380
+
381
+ .main__second__box__info
382
+
383
+ =image_tag("/images/think.jpg", width: "300", class: "main__secondImage")
384
+
385
+ .main__second__box__info__number
386
+
387
+ %h1 3
388
+
389
+ %h3 テキスト
390
+
391
+ %p テキスト
392
+
393
+ .post
394
+
395
+ .post__text
396
+
397
+ %h2 新着情報
398
+
399
+ .post__container
400
+
401
+ - @posts.each do |post|
402
+
403
+ .post__container__infomation
404
+
405
+ = link_to image_tag("#{post.image.url}", width: "80%", height: "250px"), post_path(post)
406
+
407
+ .post__container__infomation__name
408
+
409
+ = post.title
410
+
411
+ = render partial: "footer"
412
+
413
+
414
+
415
+ .icon
416
+
417
+ = link_to image_tag("/images/create.jpg", width: "120", height: "120"), new_post_path
418
+
419
+ ```

4

Rails root log/production追記

2020/04/22 02:53

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -265,3 +265,35 @@
265
265
  [capistranoを使ったEC2へのデプロイまとめ](https://qiita.com/naginx/items/fe9f9cfe942d404aa8b8)
266
266
 
267
267
  ・・・etc
268
+
269
+
270
+
271
+ # 追記
272
+
273
+ ```
274
+
275
+ [ log/production]
276
+
277
+ [ec2-user@ip- app-name]$ tail -f log/production.log
278
+
279
+ I, [2020-04-18T02:55:27.464624 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Started GET "/" for 133.106.86.67 at 2020-04-18 02:55:27 +0000
280
+
281
+ I, [2020-04-18T02:55:27.467025 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Processing by PostsController#index as HTML
282
+
283
+ I, [2020-04-18T02:55:27.471902 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Rendering posts/index.html.haml within layouts/application
284
+
285
+ D, [2020-04-18T02:55:27.495308 #6785] DEBUG -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] (0.2ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
286
+
287
+ D, [2020-04-18T02:55:27.496467 #6785] DEBUG -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Post Load (0.3ms) SELECT `posts`.* FROM `posts` ORDER BY created_at DESC LIMIT 5
288
+
289
+ I, [2020-04-18T02:55:27.501122 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Rendered posts/_footer.html.haml (2.3ms)
290
+
291
+ I, [2020-04-18T02:55:27.501316 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Rendered posts/index.html.haml within layouts/application (29.3ms)
292
+
293
+ I, [2020-04-18T02:55:27.504913 #6785] INFO -- : [a6b70f2a-64dd-4a2f-aa1b-bf0e75c99b36] Completed 200 OK in 38ms (Views: 35.6ms | ActiveRecord: 1.0ms)
294
+
295
+ D, [2020-04-20T14:50:37.925212 #4185] DEBUG -- : (5.1ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
296
+
297
+ D, [2020-04-21T05:29:54.858295 #9546] DEBUG -- : (0.2ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
298
+
299
+ ```

3

Markdown記法 URL修正

2020/04/22 01:32

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -254,16 +254,14 @@
254
254
 
255
255
  # 参考にした資料
256
256
 
257
- ```
257
+
258
-
258
+
259
- [Railsリファレンス](https://railstutorial.jp/chapters/user_microposts?version=5.1#sec-image_upload_in_production)
259
+ [Ruby on Rails チュートアル](https://railstutorial.jp/chapters/user_microposts?version=5.1#sec-image_upload_in_production)
260
-
260
+
261
- [Qiita](https://qiita.com/15grmr/items/71859caea0414f2e245d)
261
+ [【AWS】Railsで本番環境のみS3へ画像アップロードする分岐文【S3】](https://qiita.com/15grmr/items/71859caea0414f2e245d)
262
-
262
+
263
- [Qiita] (https://qiita.com/tmyn470/items/6422052f28d2a10d73cc)
263
+ [Rails5+CarrierWave+fog+Heroku+S3でデプロイした](https://qiita.com/tmyn470/items/6422052f28d2a10d73cc)
264
-
264
+
265
- [Qiita] (https://qiita.com/naginx/items/fe9f9cfe942d404aa8b8)
265
+ [capistranoを使ったEC2へのデプロイまとめ](https://qiita.com/naginx/items/fe9f9cfe942d404aa8b8)
266
266
 
267
267
  ・・・etc
268
-
269
- ```

2

URL変更

2020/04/21 09:04

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -256,13 +256,13 @@
256
256
 
257
257
  ```
258
258
 
259
- * https://railstutorial.jp/chapters/user_microposts?version=5.1#sec-image_upload_in_production
259
+ [Railsリファレンス](https://railstutorial.jp/chapters/user_microposts?version=5.1#sec-image_upload_in_production)
260
-
260
+
261
- * https://qiita.com/15grmr/items/71859caea0414f2e245d
261
+ [Qiita](https://qiita.com/15grmr/items/71859caea0414f2e245d)
262
-
262
+
263
- * https://qiita.com/tmyn470/items/6422052f28d2a10d73cc
263
+ [Qiita] (https://qiita.com/tmyn470/items/6422052f28d2a10d73cc)
264
-
264
+
265
- * https://qiita.com/naginx/items/fe9f9cfe942d404aa8b8
265
+ [Qiita] (https://qiita.com/naginx/items/fe9f9cfe942d404aa8b8)
266
266
 
267
267
  ・・・etc
268
268
 

1

誤字訂正

2020/04/21 08:59

投稿

HSRRRJSJQP
HSRRRJSJQP

スコア24

test CHANGED
File without changes
test CHANGED
@@ -12,9 +12,13 @@
12
12
 
13
13
  ```
14
14
 
15
+ なお、S3のバケットには画像が入っており、
16
+
15
- なお、S3のバケットには画像が入っており、開発環境では画像は表示できていませんが投稿はできる状態です。
17
+ 開発環境では画像は表示できていませんが投稿はできる状態です。
16
-
18
+
17
- リファレンスやその他記事などを参考に対処しましたが解決できず、申し訳ございませんが質問させて頂きます。
19
+ リファレンスやその他記事などを参考に対処しましたが解決できず、
20
+
21
+ 申し訳ございませんが質問させて頂きます。
18
22
 
19
23
  # 実現したいこと
20
24
 
@@ -68,7 +72,9 @@
68
72
 
69
73
  ```
70
74
 
71
- carrierwaveに関する指摘があったのでGit HubやWeb記事などを参考にコードを照らし合わせて修正するも状況は変わらず。
75
+ carrierwaveに関する指摘があったのでGit HubやWeb記事などを
76
+
77
+ 参考にコードを照らし合わせて修正するも状況は変わらず。
72
78
 
73
79
  併せて、 ```carrierwave```のGemをversionせずにbundle installするも解決できず。
74
80
 
@@ -84,7 +90,9 @@
84
90
 
85
91
  ```
86
92
 
87
- と記載されていたが、route.rbのどこをいじればよいか正直理解が足りず、ここに関しては何もできていない状態です。
93
+ と記載されていたが、route.rbのどこをいじればよいか
94
+
95
+ 正直理解が足りず、ここに関しては何もできていない状態です。
88
96
 
89
97
 
90
98