[Backgroundrb-devel] file_column 2nd try....

matthibcn matthibcn at gmail.com
Thu Feb 1 13:50:08 EST 2007

Looks like my first question a couple of days ago wasn´t very clever 
asked, at least very sucessfull....

So, anyway...i will try it again:

I have to prefix that I am far away from fully understanding the overall 
concept yet, and there´s no way to get some hints in the www so far, at 
least my resaerches dont lead to any helpfull stuff.


def create
MiddleMan.new_worker :class => :image_worker,
:job_key => :upload_img,
:args => { :image => params[:image]}
worker = ::MiddleMan.worker(:upload_img)


require 'RMagick'

class ImageWorker < BackgrounDRb::Worker::RailsBase

##attr_accessor :text

def do_work(args)
##@text = args[:text]
@image = Image.new(args[:image])

def progress


require 'RMagick'

class Image < ActiveRecord::Base
belongs_to :user

validates_filesize_of :image, :in => 15.kilobytes..1.megabyte
validates_file_format_of :image, :in => ["gif", "png", "jpg"]

file_column :image, :magick => {:versions => {"thumb" => "150x100", 
"picture" => "600x450>"}}

def dimensions
img = Magick::Image.read(self.image).first
if img.columns >= img.rows
ratio = img.columns.to_f / 600
ratio = img.rows.to_f / 450
self.width = ((img.columns / ratio)+10).to_i
self.height = ((img.rows / ratio)+10).to_i


So, this isn´t working...in fact I would be surprised if it would be 
that easy, as I just shifet code away from the controller to the worker...


when submitting the uploadform at least the worker get fired and passed 
the args as expected, as I can see in the backgroundrb_server.log:

20070201-10:47:29 (53830) Starting worker: image_worker upload_img 

Now there are 2 questions:

the image isnt uploaded, that is probably due to the fact that the 
file_columnPlugin isnt available for the backgrounDRbserver..

My research turned out, that for the earlier version of the backgrounDRb 
you had to insert

//require File.dirname(__FILE__) + "/../../config/environment.rb"

in the scrip/backgroundrb/start script..there is no such script in the 
actuall version and i cant see where to put that now.

So, anyway, also if the image isnt uploaded physically shouldnt i expect 
at least an DB entry for the passed args as I call the save method on 
@image ??

Further I think the dimension method should go also in the worker, but 
step by step, and I am still totaly lost, so I just ask you kindly again 
to provide some input to enlighten me and others, as I guess that a lot 
of ppl are still missing some real world examples except of some 
cronlike or outdated stuff

best regards


More information about the Backgroundrb-devel mailing list