# Model
class ProfileImage < ActiveRecord::Base
  belongs_to :employee

  has_attachment :storage => :file_system,
    :max_size => 1.megabytes,
    :thumbnails => { :thumb => '80x80>', :tiny => '40x40>' },
    :processor => :MiniMagick

  validates_as_attachment

end


#  Migration

class CreateProfileImages < ActiveRecord::Migration
  def self.up
    create_table :profile_images do |t|
      t.string :filename
      t.string :content_type
      t.integer :size
      t.integer :width
      t.integer :height
      t.integer :parent_id
      t.string :thumbnail

      t.references :employee
      t.timestamps
    end
  end

  def self.down
    drop_table :profile_images
  end
end


# View donde uso profile_image
<p>
  <b>Name:</b>
  <%=h @employee.name %>
</p>

<p>
  <b>Dni:</b>
  <%=h @employee.dni %>
</p>
<p>
  <b>Photo:</b>
  <%=  image_tag(@employee.profile_
image.public_filename(:tiny)) %>
</p>

los thumbnails se crean pero todos con el mismo tamaño, lo único que se me
ocurre es que mini_magick no esté haciendo su trabajo, revisé la tabla de
profile_images y la columna thumbnail está vacía (creo que eso no debería
ser así).

Probé hacer un resize_to pero tampoco lo redimensionó. Tengo instalado desde
las gemas mini_magick 1.3.1, ya probé reinstalar la gema pero todo sigue
igual. Alguna idea?

Saludos.
_______________________________________________
Ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

Responder a