質問編集履歴
3
pathを調べなかったのでas:を使ってパスをつくり、urlをrails routesの結果を参考に変えたが違うエラーが出てしまった。
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -56,7 +56,7 @@ | |
| 56 56 | 
             
              resources :entrances
         | 
| 57 57 | 
             
              resources :interviews
         | 
| 58 58 | 
             
              resources :interviews do
         | 
| 59 | 
            -
                patch "interviews/update" => "interviews#update"
         | 
| 59 | 
            +
                patch "interviews/update" => "interviews#update", as: :interviews_update
         | 
| 60 60 | 
             
              end
         | 
| 61 61 | 
             
            end
         | 
| 62 62 | 
             
            ```
         | 
| @@ -127,8 +127,8 @@ | |
| 127 127 | 
             
            ruby 3.1.0p0
         | 
| 128 128 | 
             
            Rails 7.0.3.1
         | 
| 129 129 |  | 
| 130 | 
            -
            ```rails routesの実行結果
         | 
| 130 | 
            +
            ```rails routesの実行結果                              
         | 
| 131 | 
            -
             | 
| 131 | 
            +
            interviews GET    /interviews(.:format)                                                                             interviews#index
         | 
| 132 132 | 
             
                                                     POST   /interviews(.:format)                                                                             interviews#create
         | 
| 133 133 | 
             
                                       new_interview GET    /interviews/new(.:format)                                                                         interviews#new
         | 
| 134 134 | 
             
                                      edit_interview GET    /interviews/:id/edit(.:format)                                                                    interviews#edit
         | 
| @@ -148,25 +148,21 @@ | |
| 148 148 |  | 
| 149 149 | 
             
            ```
         | 
| 150 150 |  | 
| 151 | 
            -
            url: | 
| 151 | 
            +
            url: interview_interviews_update_path(id: @applicant)の場合
         | 
| 152 | 
            -
            ```エラーメッセージ
         | 
| 153 | 
            -
            Rendering layout layouts/application.html.slim
         | 
| 152 | 
            +
            ```エラーメッセージRendering layout layouts/application.html.slim
         | 
| 154 153 | 
             
              Rendering interviews/edit.html.slim within layouts/application
         | 
| 155 | 
            -
              Rendered interviews/edit.html.slim within layouts/application (Duration:  | 
| 154 | 
            +
              Rendered interviews/edit.html.slim within layouts/application (Duration: 7.4ms | Allocations: 9239)
         | 
| 156 | 
            -
              Rendered layout layouts/application.html.slim (Duration:  | 
| 155 | 
            +
              Rendered layout layouts/application.html.slim (Duration: 7.7ms | Allocations: 9333)
         | 
| 157 | 
            -
            Completed 500 Internal Server Error in  | 
| 156 | 
            +
            Completed 500 Internal Server Error in 12ms (ActiveRecord: 0.1ms | Allocations: 10695)
         | 
| 158 157 |  | 
| 159 158 |  | 
| 160 159 |  | 
| 161 | 
            -
            ActionView::Template::Error ( | 
| 162 | 
            -
             | 
| 163 | 
            -
            ; @output_buffer.safe_concat(("</div>".freeze)); _slim_controls1 = form_with model: @applicant, url:interviews_update_path(id: @applicant),  local: true do |f|; 
         | 
| 164 | 
            -
                                                                                                                ^^^^^^^^^^^^^^^^^^^^^^
         | 
| 165 | 
            -
            Did you mean?  interviews_path):
         | 
| 160 | 
            +
            ActionView::Template::Error (No route matches {:action=>"update", :controller=>"interviews", :id=>#<Applicant id: 4, family_name: "agf", given_name: "gaff", reception_number: 301, gender: 1, receptionist: "fad", created_at: "2022-08-30 07:21:20.242973000 +0000", updated_at: "2022-08-30 07:21:20.242973000 +0000", selection_economic: 0, selection_abroad: 0, document_nyuryonegai: 0, document_sankousyorui: 0, document_juminhyo: 0, document_gakuseki: 0, document_keizai: 0>}, missing required keys: [:interview_id]
         | 
| 161 | 
            +
            Did you mean?  interview_interviews_update_url):
         | 
| 166 162 | 
             
                4: .nav.justify-contnet-end
         | 
| 167 163 | 
             
                5:     = link_to '一覧', interviews_path, class: 'nav-link'
         | 
| 168 164 | 
             
                6: 
         | 
| 169 | 
            -
                7: = form_with model: @applicant, url: | 
| 165 | 
            +
                7: = form_with model: @applicant, url:interview_interviews_update_path(id: @applicant),  local: true do |f|
         | 
| 170 166 | 
             
                8:     .form_group
         | 
| 171 167 | 
             
                9:         = f.label :family_name
         | 
| 172 168 | 
             
               10:         = f.text_field :family_name, class: 'form-control', id: 'family_name'
         | 
2
rails routes の結果
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -125,4 +125,51 @@ | |
| 125 125 | 
             
            ```
         | 
| 126 126 |  | 
| 127 127 | 
             
            ruby 3.1.0p0
         | 
| 128 | 
            -
            Rails 7.0.3.1
         | 
| 128 | 
            +
            Rails 7.0.3.1
         | 
| 129 | 
            +
             | 
| 130 | 
            +
            ```rails routesの実行結果
         | 
| 131 | 
            +
             interviews GET    /interviews(.:format)                                                                             interviews#index
         | 
| 132 | 
            +
                                                     POST   /interviews(.:format)                                                                             interviews#create
         | 
| 133 | 
            +
                                       new_interview GET    /interviews/new(.:format)                                                                         interviews#new
         | 
| 134 | 
            +
                                      edit_interview GET    /interviews/:id/edit(.:format)                                                                    interviews#edit
         | 
| 135 | 
            +
                                           interview GET    /interviews/:id(.:format)                                                                         interviews#show
         | 
| 136 | 
            +
                                                     PATCH  /interviews/:id(.:format)                                                                         interviews#update
         | 
| 137 | 
            +
                                                     PUT    /interviews/:id(.:format)                                                                         interviews#update
         | 
| 138 | 
            +
                                                     DELETE /interviews/:id(.:format)                                                                         interviews#destroy
         | 
| 139 | 
            +
                         interview_interviews_update PATCH  /interviews/:interview_id/interviews/update(.:format)                                             interviews#update
         | 
| 140 | 
            +
                                                     GET    /interviews(.:format)                                                                             interviews#index
         | 
| 141 | 
            +
                                                     POST   /interviews(.:format)                                                                             interviews#create
         | 
| 142 | 
            +
                                                     GET    /interviews/new(.:format)                                                                         interviews#new
         | 
| 143 | 
            +
                                                     GET    /interviews/:id/edit(.:format)                                                                    interviews#edit
         | 
| 144 | 
            +
                                                     GET    /interviews/:id(.:format)                                                                         interviews#show
         | 
| 145 | 
            +
                                                     PATCH  /interviews/:id(.:format)                                                                         interviews#update
         | 
| 146 | 
            +
                                                     PUT    /interviews/:id(.:format)                                                                         interviews#update
         | 
| 147 | 
            +
                                                     DELETE /interviews/:id(.:format)                                                                         interviews#destroy
         | 
| 148 | 
            +
                                   
         | 
| 149 | 
            +
            ```
         | 
| 150 | 
            +
             | 
| 151 | 
            +
            url:nterviews_update_path(id: @applicant)の場合
         | 
| 152 | 
            +
            ```エラーメッセージ
         | 
| 153 | 
            +
            Rendering layout layouts/application.html.slim
         | 
| 154 | 
            +
              Rendering interviews/edit.html.slim within layouts/application
         | 
| 155 | 
            +
              Rendered interviews/edit.html.slim within layouts/application (Duration: 17.2ms | Allocations: 4966)
         | 
| 156 | 
            +
              Rendered layout layouts/application.html.slim (Duration: 17.4ms | Allocations: 5054)
         | 
| 157 | 
            +
            Completed 500 Internal Server Error in 21ms (ActiveRecord: 0.1ms | Allocations: 5779)
         | 
| 158 | 
            +
             | 
| 159 | 
            +
             | 
| 160 | 
            +
              
         | 
| 161 | 
            +
            ActionView::Template::Error (undefined method `interviews_update_path' for #<ActionView::Base:0x0000000017c000>
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            ; @output_buffer.safe_concat(("</div>".freeze)); _slim_controls1 = form_with model: @applicant, url:interviews_update_path(id: @applicant),  local: true do |f|; 
         | 
| 164 | 
            +
                                                                                                                ^^^^^^^^^^^^^^^^^^^^^^
         | 
| 165 | 
            +
            Did you mean?  interviews_path):
         | 
| 166 | 
            +
                4: .nav.justify-contnet-end
         | 
| 167 | 
            +
                5:     = link_to '一覧', interviews_path, class: 'nav-link'
         | 
| 168 | 
            +
                6: 
         | 
| 169 | 
            +
                7: = form_with model: @applicant, url:interviews_update_path(id: @applicant),  local: true do |f|
         | 
| 170 | 
            +
                8:     .form_group
         | 
| 171 | 
            +
                9:         = f.label :family_name
         | 
| 172 | 
            +
               10:         = f.text_field :family_name, class: 'form-control', id: 'family_name'
         | 
| 173 | 
            +
              
         | 
| 174 | 
            +
            app/views/interviews/edit.html.slim:7
         | 
| 175 | 
            +
            ```
         | 
1
routes.rb ,エラーメッセージを全文載せました。edit.html.slimを(特定を避ける為)変数名を変えて全文載せました。お手数おかけしました。見ていただけると大変助かります。
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -23,7 +23,30 @@ | |
| 23 23 |  | 
| 24 24 | 
             
            ```
         | 
| 25 25 | 
             
            エラーメッセージ
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Started PATCH "/interviews/1/interviews/update" for ::1 at 2022-08-31 10:19:40 +0900
         | 
| 28 | 
            +
            Processing by InterviewsController#update as TURBO_STREAM
         | 
| 29 | 
            +
              Parameters: {"authenticity_token"=>"[FILTERED]", "applicant"=>{"family_name"=>"hoge", "given_name"=>"huga", "gender"=>"0", "selection_economic"=>"1", "selection_abroad"=>"0", "document_nyukainegai"=>"1", "document_sankousyorui"=>"1", "document_juminhyo"=>"0", "document_shikaku"=>"0", "document_keizai"=>"0", "receptionist"=>"naya"}, "commit"=>"Update 入会希望者", "interview_id"=>"1"}
         | 
| 30 | 
            +
               (0.1ms)  SELECT sqlite_version(*)
         | 
| 31 | 
            +
              ↳ app/controllers/interviews_controller.rb:11:in `update'
         | 
| 32 | 
            +
            Completed 404 Not Found in 11ms (ActiveRecord: 0.9ms | Allocations: 2416)
         | 
| 33 | 
            +
             | 
| 34 | 
            +
             | 
| 35 | 
            +
              
         | 
| 26 36 | 
             
            ActiveRecord::RecordNotFound (Couldn't find Applicant without an ID):
         | 
| 37 | 
            +
              
         | 
| 38 | 
            +
            app/controllers/interviews_controller.rb:11:in `update'
         | 
| 39 | 
            +
            Started GET "/interviews/1/edit" for ::1 at 2022-08-31 10:19:40 +0900
         | 
| 40 | 
            +
            Processing by InterviewsController#edit as HTML
         | 
| 41 | 
            +
              Parameters: {"id"=>"1"}
         | 
| 42 | 
            +
              Applicant Load (0.2ms)  SELECT "applicants".* FROM "applicants" WHERE "applicants"."id" = ? LIMIT ?  [["id", 1], ["LIMIT", 1]]
         | 
| 43 | 
            +
              ↳ app/controllers/interviews_controller.rb:7:in `edit'
         | 
| 44 | 
            +
              Rendering layout layouts/application.html.slim
         | 
| 45 | 
            +
              Rendering interviews/edit.html.slim within layouts/application
         | 
| 46 | 
            +
              Rendered interviews/edit.html.slim within layouts/application (Duration: 6.4ms | Allocations: 3717)
         | 
| 47 | 
            +
              Rendered layout layouts/application.html.slim (Duration: 31.7ms | Allocations: 20857)
         | 
| 48 | 
            +
            Completed 200 OK in 41ms (Views: 33.1ms | ActiveRecord: 0.5ms | Allocations: 25900)
         | 
| 49 | 
            +
             | 
| 27 50 | 
             
            ```
         | 
| 28 51 |  | 
| 29 52 | 
             
            ### 該当のソースコード
         | 
| @@ -32,7 +55,10 @@ | |
| 32 55 | 
             
            Rails.application.routes.draw do
         | 
| 33 56 | 
             
              resources :entrances
         | 
| 34 57 | 
             
              resources :interviews
         | 
| 58 | 
            +
              resources :interviews do
         | 
| 59 | 
            +
                patch "interviews/update" => "interviews#update"
         | 
| 35 | 
            -
             | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
| 36 62 | 
             
            ```
         | 
| 37 63 |  | 
| 38 64 | 
             
            #### interviews/edit.html.slim
         | 
| @@ -41,7 +67,38 @@ | |
| 41 67 | 
             
                .form_group
         | 
| 42 68 | 
             
                    = f.label :family_name
         | 
| 43 69 | 
             
                    = f.text_field :family_name, class: 'form-control', id: 'family_name'
         | 
| 70 | 
            +
                    = f.label :given_name
         | 
| 71 | 
            +
                    = f.text_field :given_name, class: 'form-control', id: 'given_name'
         | 
| 72 | 
            +
                    = f.label :gender, '男性'
         | 
| 73 | 
            +
                    = f.radio_button :gender, 0
         | 
| 74 | 
            +
                    = f.label :gender, '女性'
         | 
| 75 | 
            +
                    = f.radio_button :gender, 1
         | 
| 44 | 
            -
             | 
| 76 | 
            +
                    br
         | 
| 77 | 
            +
                    = f.check_box :selection_economic, {}, 1, 0
         | 
| 78 | 
            +
                    = f.label :selection_economic
         | 
| 79 | 
            +
                    br
         | 
| 80 | 
            +
                    = f.check_box :selection_abroad, {}, 1, 0
         | 
| 81 | 
            +
                    = f.label :selection_abroad
         | 
| 82 | 
            +
                    br
         | 
| 83 | 
            +
                    br
         | 
| 84 | 
            +
                    = f.check_box :document_nyukainegai, {}, 1, 0
         | 
| 85 | 
            +
                    = f.label :document_nyuryonegai
         | 
| 86 | 
            +
                    br
         | 
| 87 | 
            +
                    = f.check_box :document_sankousyorui, {}, 1, 0
         | 
| 88 | 
            +
                    = f.label :document_sankousyorui
         | 
| 89 | 
            +
                    br
         | 
| 90 | 
            +
                    = f.check_box :document_juminhyo, {}, 1, 0
         | 
| 91 | 
            +
                    = f.label :document_juminhyo
         | 
| 92 | 
            +
                    br
         | 
| 93 | 
            +
                    = f.check_box :document_shikaku, {}, 1, 0
         | 
| 94 | 
            +
                    = f.label :document_gakuseki
         | 
| 95 | 
            +
                    br
         | 
| 96 | 
            +
                    = f.check_box :document_keizai, {}, 1, 0
         | 
| 97 | 
            +
                    = f.label :document_keizai
         | 
| 98 | 
            +
                    br
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                    = f.label :receptionist
         | 
| 101 | 
            +
                    = f.text_field :receptionist, class: 'form-control', id: 'receptionist'
         | 
| 45 102 | 
             
                = f.submit nil, class: 'btn btn-primary'
         | 
| 46 103 |  | 
| 47 104 | 
             
            ...
         |