List all associations as links in the active admin

Is it possible in active admin to list all the associations of has_manymy record as links?

The code should look something like this:

column "belongs to" do |b|
    b.associations.map { |a| link_to(a.name, admin_association_path(a) }
end

But this generates a list of tags that do not appear as links available for the link.

+4
source share
1 answer

mapcreates an array of html lines, so you need jointo get them one line, and then mark it as html-safe.

column "belongs to" do |b|
    b.associations
     .map { |a| link_to(a.name, admin_association_path(a)) }
     .join
     .html_safe
end
+5
source

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


All Articles