Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 ActiveAdmin Papperclip在索引和显示中显示多个图像_Ruby On Rails 4_Paperclip_Activeadmin_Nested Forms - Fatal编程技术网

Ruby on rails 4 ActiveAdmin Papperclip在索引和显示中显示多个图像

Ruby on rails 4 ActiveAdmin Papperclip在索引和显示中显示多个图像,ruby-on-rails-4,paperclip,activeadmin,nested-forms,Ruby On Rails 4,Paperclip,Activeadmin,Nested Forms,您好,这只是一个关于在索引页和显示页上显示多个图像的快速问题。我的图像以product_id作为外键存储在product_images表中 在这件事上兜圈子。我尝试过使用类似的代码,但没有效果 row "Images" do ul do product.images.each do |img| li do image_tag(img.image.url(:small)) end

您好,这只是一个关于在索引页和显示页上显示多个图像的快速问题。我的图像以product_id作为外键存储在product_images表中

在这件事上兜圈子。我尝试过使用类似的代码,但没有效果

 row "Images" do
        ul do
          product.images.each do |img|
            li do
              image_tag(img.image.url(:small))
            end
          end
        end
      end

索引do
列:id
列:产品名称
栏目:产品描述
“图像”列do | m|
m、 产品|图像。每个都有|图像|
广度
图像\标签(img.product\图像.url(:thumb))
终止
终止
终止
行动
终止
显示标题::产品名称do
属性表do
#其他行
行:id
行:产品名称
行:产品描述
行“图像”do | m|
m、 产品|图像。每个都有|图像|
广度
图像\标签(img.product\图像.url(:thumb))
终止
终止
终止
终止
结束
ActiveAdmin.register Product do

  # See permitted parameters documentation:
  # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
  #
   permit_params :id, :product_name, :product_description, :product_type_id, :product_category_id, :product_colour_id, :product_size_id,
                             product_images_attributes: [:id, :product_id, :product_image, :_destroy ]
  #
  # or
  #
  # permit_params do
  #   permitted = [:permitted, :attributes]
  #   permitted << :other if resource.something?
  #   permitted
  # end

  index do
          column :id
          column :product_name
          column :product_description

    actions
  end

   form(:html => {:multipart => true}) do |f|
     f.inputs "Product Details" do
       f.input :id
       f.input :product_name
       f.input :product_description

       f.inputs "Product images" do
         f.has_many :product_images do |p|
           p.input :product_image, :as => :file, :label => "Image",:hint => image_tag(p.object.product_image.url(:thumb))
           p.input :_destroy, :as=>:boolean, :required => false, :label => 'Remove image'
         end
       end
        f.actions
   end
end


  show title: :product_name do

    attributes_table do
      # other rows
      row :id
      row :product_name
      row :product_description

      end
  end

end
index do
      column :id
      column :product_name
      column :product_description
      column "Images" do |m|
        m.product_images.each do |img|
          span do
            image_tag(img.product_image.url(:thumb))
          end
        end
      end
      actions
 end

 show title: :product_name do

attributes_table do
  # other rows
  row :id
  row :product_name
  row :product_description
      row "Images" do |m|
        m.product_images.each do |img|
          span do
           image_tag(img.product_image.url(:thumb))
         end
        end
       end
      end
  end