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.

ActiveAdmin 画面遷移時にfilterのパラメーターをセットする

Posted at

親要素から子要素に遷移する際, 親要素のidで絞りたい

これだけと何をいってるかわからないので

例)
Company : Shop = 1 : N のRelationの時,

Companyの画面から, Shopの一覧画面へ遷移する時,
そのままではデータが大きすぎるので,
最初からShopを外部キーのCompany_Idで絞っておきたい

  # カスタム アクション
  # 一度変数に入れないと, エスケープされずエラーとなる
  query = "q[company_id_equals]"
  action_item :my_button1, only: :show do
    link_to "店舗の一覧に遷移する", active_admin_shops_path({query => company.id})
  end

これだけで遷移と同時にfilterがかかります.
調べても載っておらず, 尚且つ需要があると思うので書きました.

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?