0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

患者(ユーザー)ごとにindex表示したい whereを使う

Posted at

1)患者(ユーザー)ごとにindex表示したい


患者1 ーーー患者3の記録 患者2の記録のようになってしまった

staff/record/index.html.erb
def index
    @records = Record.all(params[:patient_id]).page(params[:page]).per(7).reverse_order
end
  ↓↓↓↓↓↓
def index
    @records = Record.where(patient_id: params[:patient_id]).page(params[:page]).per(7).reverse_order
end

ユーザーごとに投稿&自分の投稿一覧indexしか見えないのが正しい、 でも見えちゃう問題

``` def index @dialies = Dialy.all       end としていた。他のユーザー記録が見える.... ```

current_ whereを用いる

 def index
    @dialies = current_patient.dialies.all
    あるいは
    @dialies = Dialy.where( parient.id: current_patient.id)
  #全体の中から絞って持ってくる     
  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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?