Nihal Nizar
Nihal Nizar

Reputation: 165

ActiveAdmin - Index as grid - multiple field

I have a picture model with attributes 'img' and 'caption'

I rendered the images using index as grid

index as: :grid, columns: 2 do |pic|
  link_to image_tag(pic.image), admin_pic_path(pic)
end

This renders all the images without any problem. I also want caption along with the images so that i have a heading for each image. Anyone knows how to solve this ?Is it possible to render multiple fields using index as grid ?

Upvotes: 3

Views: 1117

Answers (1)

Maxim
Maxim

Reputation: 9961

I think if you want to write easy and clear code you should use Arbre instead of using Rails tag helpers like link_to and image_tag:

index as: :grid do |product|
    a href: admin_pic_path(pic) do
        img src: image_path(pic.image), alt: pic.title
        div pic.caption
    end
end

Upvotes: 4

Related Questions