Forum: Ruby on Rails file_column with RMagick

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
alex (Guest)
on 2005-11-14 16:32
(Received via mailing list)
I think I must be being really dense...  I just can't get resizing
versions to work with RMagick.  Can someone show me an example of a
working configuration?

I'm using Rails 0.14.3, file_column 0.3, and the following doesn't work:

== db/migrate/010_add_image.rb

class AddItems < ActiveRecord::Migration
	self.up
		add_column :items, :image, :string
	end
end

== app/models/item.rb

class Item < ActiveRecord::Base
	file_column :image, :magick => {:versions =>
		     {	"thumb" => "50x50",
			"medium" => "640x480>"}  }
end

== app/controllers/item_controller.rb

class ItemController < ApplicationController
	def upload_image
		@item = Item.find(params[:id])
		@item.image=params[:item][:image]
		@item.save
		redirect_to :action => 'show', :id => params[:id]
	end
end

== app/views/item/show.rhtml

<%= image_tag url_for_file_column('item', 'image', 'medium') %>

==

The last image tag comes out broken, and the thumbnail isn't created.
No errors are showing in the logs, and google's not being much help.
Is there anything obvious I've missed out?
eric (Guest)
on 2005-11-14 16:41
(Received via mailing list)
I spent a day or so fighting this same thing, and it turned out that I
didn't have RMagick properly installed as a gem.

I actually couldn't install the gem on any of my environment
platforms, but I was able to get it all working by changing line 84 of
magick_file_column.rb from "require-gem 'rmagick'" to "require
'RMagick'"

I understand future versions of file_column (which I *love*, by the
way) will be more forgiving of how you've got RMagick installed.

-eric
alex (Guest)
on 2005-11-14 16:53
(Received via mailing list)
Eric W. wrote:
> I actually couldn't install the gem on any of my environment
> platforms, but I was able to get it all working by changing line 84 of
> magick_file_column.rb from "require-gem 'rmagick'" to "require
> 'RMagick'"
Already done that - I was clued in by Item.find(2) barfing in
script/console.  Still no worky.

--
Alex
This topic is locked and can not be replied to.