Activeadmin link_to

Hello, I have to make some links on the Active Admin administration pages, but I have some problems understanding the hashes to search 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 do not understand the meaning:

 ('q[advertiser_id_eq]') 

Why is it inside "q []" and has "_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 do a search for related information in relation on models, but when I change it to normal:

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

it just sends me to the normal index of all the "campaigns" in this latter case. The documentation for activeadmin doesn’t say much about how search queries work.

+4
source share
2 answers

The active administrator uses the meta search stone to search for results. Try using q [by_campaign_id] => "# {campaign.id}"

+1
source
 'q[advertiser_id_eq]' => advertiser.id 'q[by_campaign_id]' => campaign.id 

these two do not work in my code, it just shows all the campaigns. he needs

 'q[advertiser_id_eq]' => "#{advertiser.id}" 
-1
source

Source: https://habr.com/ru/post/1435575/


All Articles