Mark as image in the list (index) of ActiveAdmin.

Asked 2 years ago, Updated 2 years ago, 93 views

Rails has a column called image_url in the model, how do I display this image in the index of ActiveAdmin?

ruby-on-rails activeadmin

2022-09-21 17:17

1 Answers

When the model is named stack,

index do
    column :id
    column "Image" do |stack|
      if !stack.image_url.nil?
        image_tag stack.image_url, class: 'stack_image'
      end
    end
    #Other column information...

Hani works well.

If the width is not determined through class 'stack_image', it will be displayed as the original image size, so it is convenient to specify the size in active_admin.scss.


2022-09-21 17:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.