简体   繁体   English

Ruby on Rails活动管理映像占位符

[英]Ruby on Rails Active Admin image Placeholders

I am using activeadmin as the admin interface for an application I am working on and am trying to work out how to get image URL's to display as placeholders if an image is already uploaded. 我正在使用activeadmin作为正在处理的应用程序的管理界面,并且正在尝试弄清楚如果已上传图像,如何获取图像URL以显示为占位符。

Activeadmin works using simpleform so in theory it should be relatively easy but I seem to be struggling. Activeadmin使用simpleform进行工作,因此从理论上讲应该比较容易,但是我似乎很挣扎。

The code I currently have is: 我目前拥有的代码是:

ActiveAdmin.register Place do
...
show do |place|
    attributes_table do
    ...
    (1..6).each do |i|
        row(:"image_#{i}") do
          if place.send("image_#{i}").present?
            image_tag(place.send("image_#{i}").index)
          else
            "None"
          end
        end
      end
      (1..6).each do |i|
        row(:"mood_board_image_#{i}") do
          if place.send("mood_board_image_#{i}").present?
            image_tag(place.("mood_board_image_#{i}").index)
          else
            "None"
          end
        end
      end
    end
  end
....
end

At the moment I am just getting the default 'No file chosen' text when in the activeadmin interface. 目前,在activeadmin界面中,我只是获得默认的“未选择文件”文本。 Any help would be very much appreciated :) 任何帮助将不胜感激:)

The first arg in image_tag should be the source of the image: http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag image_tag中的第一个arg应该是图像的来源: http : //apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag

if 'there is image url'
  image_tag(url_of_the_image)
else
  #your_button_whit_your_text
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM