1
1

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.

Ransackのsort_linkで孫テーブルの値でソートする

Posted at

めちゃめちゃハマったので個人的なメモ。

親を表示してるけど中間テーブルを通して別テーブルの値を表示していて、その列をソートしたいとき

<%# 子テーブル名_孫テーブル名_属性名 %>
<%= sort_link(@q, :child_grandchild_name, '孫の名前') %>

でいける。
テーブル名に"_"が入ってても大丈夫。

1
1
1

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?