Reputation: 5492
I am working with ActiveAdmin in a Rails project. I want to add more than one action in a column in ActiveAdmin view, here is what I am trying to do:
index do |company|
selectable_column
id_column
column :name
column :email
column :phone
column :created_at
column "Actions" do |company|
link_to 'View', "companies/#{company.id}"
if company.jobs.present?
link_to 'View Jobs Posted', {:controller => "jobs", :action => "index", 'q[company_id_eq]' => company.id}
end
end
end
In the above code I am trying to add two actions in column "Actions", but the thing is it overwrites the first action ('View') and only show the action ('View Jobs Posted').
Upvotes: 2
Views: 2080
Reputation: 6438
You can do this way to show multiple link_to under single column same as like default actions, "View Edit Delete".
column "Change Status" do |complaint|
(link_to "Approved", approved_path(product, q: "approved")) + " " +
(link_to "Not Approved", approved_path(product, q: "not_approved"))
end
Upvotes: 3
Reputation: 144
Instead of
link_to 'View', "companies/#{company.id}"
.
Try : link_to 'View', admin_company_path(company)
EDIT 1 :
or link_to 'View', company_path(company)
if you want to render the show page of the controller 'company'.
Upvotes: -1