Search code examples
adminlink-to

activeadmin link_to


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


Solution

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