我有一个自关联模型,允许用户定义“父照片”,以便将它们组合在一起.
我的模特:
class Photo < ActiveRecord::Base attr_accessible :image,:parent_photo has_attached_file :image,:styles => { :medium => "300x300>",:thumb => "100x100>" } validates_attachment :image,:presence => true,:size => { :in => 20..2000.kilobytes },:content_type => { :content_type => [ 'image/jpeg','image/png' ] } belongs_to :parent,class_name: "Photo",foreign_key: :parent_photo def associated_photos Photo.find_by_parent_photo(id) end end
在我的rails_admin初始化程序中:
.. config.model Photo do list do field :image field :associated_photos end end end
如何检索实际缩略图以在列表操作中使用?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。