4

Hello i have to make some links in the Active Admin admin pages, but i have some problems understanding the hashes to make searches for specific entries, for example:

column 'Campaigns' do |advertiser|
  link_to "#{advertiser.campaigns.count} campaigns", admin_campaigns_path('q[advertiser_id_eq]' => advertiser.id)
end

I dont understand the meaning of:

('q[advertiser_id_eq]')

Why is it inside a "q[]" and has a "_eq?"

or:

column 'Entrants' do |campaign|
      link_to "#{campaign.entrants.count} entrants", admin_entrants_path('q[by_campaign_id]' => campaign.id)
end

When i click the links they make a search for the linked information in the relation at the models but when i change it for a normal:

('[campaign_id]' => campaign.id)

it just sends me to the normal index of all the "campaigns" in this last case. the documentation for activeadmin dont realy say much about how the searches work

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304

2 Answers2

1

Active admin uses meta search gem to search results. Try using q[by_campaign_id] => "#{campaign.id}"

nilay
  • 365
  • 1
  • 10
-1
'q[advertiser_id_eq]' => advertiser.id
'q[by_campaign_id]' => campaign.id

these two don't work in my code, it just shows all the campaigns. it should like

'q[advertiser_id_eq]' => "#{advertiser.id}"
DiuDiugirl
  • 71
  • 1
  • 7