LoginSignup
0
0

More than 1 year has passed since last update.

9.15振り返り  パスが飛ばせない、ユーザーごとの一覧表示できない問題

Posted at

1)pathを確認して書いたのに動かない

=link_to "詳細",staff_patient_record_path(patient_id,record.id)"%>でエラー

staff/record/index.html.erb
<%@records.each do |record|%>                                       エラー
:                                                                                           ↓↓↓
# =link_to "詳細を見る",staff_patient_record_path(patient_id, record.id)"%>でエラー                                            
:
<%end%>
 staff_patient_record GET    /staff/patients/:patient_id/records/:id(.:format)                                        staff/records#show

patients/:patient_idとrecords/:idが必要なのはわかった  指定しても動かない

patient_id→→record.patient_idモデルで持ってくる

staff/record/index.html.erb
<%@records.each do |record|%>の中にあるためrecordがない、急にpatientは使えない
:
# =link_to "詳細を見る",staff_patient_record_path(patient_id, record.id)"%>でエラー
                                                  ↓↓↓ model:recordで持ってくる
<%=link_to "詳細を見る",staff_patient_record_path(record.patient_id, record.id)"%>
:
<%end%>
model/record.rb
class Record < ApplicationRecord
:   #recordモデルで紐づけているため明示すれば持ってこれる
   belongs_to :patient
:
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0