質問編集履歴

3

2023/02/09 00:21

投稿

hanahana1
hanahana1

スコア3

test CHANGED
File without changes
test CHANGED
@@ -16,11 +16,9 @@
16
16
 
17
17
  class OfferMailerPreview < ActionMailer::Preview
18
18
  def offer_mail(offer)
19
- mail to: @offer.**job.**company.email, subject: "応募のお知らせ" 
19
+ mail to: @offer.job.company.email, subject: "応募のお知らせ" 
20
20
  end
21
21
  end
22
-
23
- **このjobに対して、@offerが空です、というエラーが起きています↑**
24
22
 
25
23
  Rails.root: /Users/ユーザー名/projects/アプリ名
26
24
 
@@ -102,7 +100,6 @@
102
100
  end
103
101
  end
104
102
 
105
- **createアクション内で@offerを定義しているのですが、エラーは変わっていないです↑**
106
103
 
107
104
  private
108
105
  def offer_params

2

エラー文を一部修正(いらない部分の削除)

2023/02/09 00:18

投稿

hanahana1
hanahana1

スコア3

test CHANGED
File without changes
test CHANGED
@@ -12,43 +12,41 @@
12
12
  ```
13
13
  NoMethodError in OffersController#create
14
14
  undefined method `job' for nil:NilClass
15
- Extracted source (around line #4):
15
+ Extracted source (around line #3):
16
- 2
17
- 3
18
- 4
19
- 5
20
- 6
21
16
 
22
17
  class OfferMailerPreview < ActionMailer::Preview
23
18
  def offer_mail(offer)
24
- mail to: @offer.job.company.email, subject: "応募のお知らせ"
19
+ mail to: @offer.**job.**company.email, subject: "応募のお知らせ" 
25
20
  end
26
21
  end
22
+
23
+ **このjobに対して、@offerが空です、というエラーが起きています↑**
27
24
 
28
25
  Rails.root: /Users/ユーザー名/projects/アプリ名
29
26
 
30
27
  Application Trace | Framework Trace | Full Trace
31
- app/models/offer_mailer_preview.rb:4:in `offer_mail'
28
+ app/models/offer_mailer_preview.rb:3:in `offer_mail'
32
29
  app/controllers/offers_controller.rb:16:in `create'
33
30
  Request
34
31
  Parameters:
35
32
 
36
- {"authenticity_token"=>"PiYilhxlTeYHlVCsiGTum1QuH5pakK0fquTavBZXay+9IF7SKF0haPQ6hLkqhXKLNkAsua3QqB7iM4cFeR4qfA==",
33
+ {"authenticity_token"=>"VhrbUzzf6Cxz6gr/kVAPj0iEI5jb4oYZ9e1dUWgnCgWCF2MfE8ZaDBeD4/V5rwGm/irlfCuYVf6Fi4E9WVZicA==",
37
34
  "offer"=>
38
- {"last_name"=>"山田",
35
+ {"last_name"=>"",
39
- "first_name"=>"花子",
36
+ "first_name"=>"",
40
37
  "email"=>"a@a",
41
- "age"=>"20",
38
+ "age"=>"25",
42
- "prefecture_id"=>"4",
39
+ "prefecture_id"=>"2",
43
- "city"=>"",
40
+ "city"=>"十勝市十勝町",
44
- "house_number"=>"",
41
+ "house_number"=>"1丁目1番地",
45
- "building"=>"",
42
+ "building"=>"",
46
43
  "phone_number"=>"000-0000-0000",
47
44
  "academic_career"=>"a",
48
45
  "work_history"=>"a",
49
46
  "appeal"=>"a"},
50
47
  "commit"=>"送信する",
51
48
  "job_id"=>"4"}
49
+
52
50
  ```
53
51
 
54
52
  ### 該当のソースコード
@@ -78,6 +76,7 @@
78
76
  resources :articles, only: [:new, :create, :edit, :update, :destroy]
79
77
  end
80
78
  end
79
+
81
80
  ```
82
81
 
83
82
  ```offers_controller.rb
@@ -103,6 +102,7 @@
103
102
  end
104
103
  end
105
104
 
105
+ **createアクション内で@offerを定義しているのですが、エラーは変わっていないです↑**
106
106
 
107
107
  private
108
108
  def offer_params

1

誤字

2023/02/08 11:59

投稿

hanahana1
hanahana1

スコア3

test CHANGED
File without changes
test CHANGED
@@ -25,7 +25,7 @@
25
25
  end
26
26
  end
27
27
 
28
- Rails.root: /Users//projects/tsunagu
28
+ Rails.root: /Users/ユーザー名/projects/アプリ名
29
29
 
30
30
  Application Trace | Framework Trace | Full Trace
31
31
  app/models/offer_mailer_preview.rb:4:in `offer_mail'