2016-11-23 9 views
2

나는 다음과 같은 코드가 있습니다은 관리자 디스플레이 레일 : 엄지 손가락 이미지를

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

예, 방금 새 프로젝트를 추가했는데 이미지가 여전히 매우 큰 것처럼 표시됩니다! –

+0

: content_type => 'application/pdf'왜 PDF의 유효성을 검사합니까 ?? –

답변

0

validates_attachment_content_type :file, :content_type => 'application/pdf' 

하고 이미지를 기대하고 있습니다 것은 내가 다시

https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation

+0

크기 조정을 올바른 모델로 옮겼지만 인덱스 페이지에서 여전히 큰 이미지를 얻고 있습니다. –

+0

새 프로젝트를 만드십시오. –

+0

아니면 Project.find_each {| u | u.file.reprocess! } 기존 파일의 축소판을 만들려면 –