Vlad Balanescu Vlad Balanescu - 14 days ago 4
Ruby Question

Rails admin display :thumb image

I have the following code:

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


Question: On the list view, why don't I get that
:thumb
image and I get a very very large image? I guess the chopping procedure is not working at all?

Answer

There is

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

and you are expecting images to be resized I think you check your modal and implementation again

Follow this

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