我有以下代码:
config/initializers/rails_admin.rb
list do
field :id #currentId set in app/views/rails_admin/main/index
field :year
field :title
field :intro
field :description
field :confidential
field :star
field :image do
formatted_value do
bindings[:view].tag(:img, { :src => bindings[:object].image.url(:thumb)})
end
end
end
app/models/submission.rb
class Submission < ActiveRecord::Base
# Image attachment and validations
has_attached_file :file,
:url => "/files/:class/:attachment/:id/:style/:basename.:extension",
:path => ":rails_root/public/files/:class/:attachment/:id/:style/:basename.:extension",
:styles => { :thumb => "100x100#", :small => "150x150>", :medium => "200x200" }
# Validate attachment type
validates_attachment_content_type :file, :content_type => 'application/pdf'
end
问题:在列表视图中,为什么我不能获得:thumb
图像,而是获得非常大的图像?我猜斩波程序根本不起作用?
答案 0 :(得分:0)
有
validates_attachment_content_type :file, :content_type => 'application/pdf'
并且您希望调整图像大小我想你再次检查你的模态和实现
关注此
https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation