0

I just installed RMagick and am trying to display a thumbnail of any image I throw at it on my webpage. But the code from the tutorial opens up a new window in order to show my image. Here's what I have.

require 'RMagick'

class StaticPagesController < ApplicationController
  include Magick

  def home
    @cat = ImageList.new("app/assets/images/me.jpg")
  end
end

and the view:

<%= @cat.display %>

I want the image to be displayed on the page instead a new window pops up displaying the image and this is displayed on the page:

#<Magick::ImageList:0x007f564804bb18>

UPDATE

I need to resize the image before I display it.

Mike Glaz
  • 5,352
  • 8
  • 46
  • 73

1 Answers1

0

From the documentation of display:

Displays the images in the imagelist to any X Window screen. By default displays to the local screen. You can specify a different screen by assigning the name to the server_name attribute in the optional arguments block.

That's not the right method to use in a HTML page. If you already have the image saved, you don't need to load it back into an ImageList. You can just display it in your view:

<%= image_tag "me.jpg" %>

should do the trick.

Thilo
  • 17,565
  • 5
  • 68
  • 84