我有以下代碼:Rails的管理員顯示:拇指圖像
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
圖像和我得到一個非常大的圖像?我猜斬波程序根本不起作用?
你有沒有創建新提交後添加這種風格的配置? –
是的,我剛剛添加了一個新項目,圖像仍然顯示爲非常大! –
:content_type =>'application/pdf'爲什麼要驗證PDF? –