Topic: Is a directory - read on Image.create

I'm trying to create an app where a user can upload a zip file of pictures, and then resize them to the specified length. I've used one zip file and it works perfectly, however when I use another one (and this one's bigger), I get the error "Is directory-read". The specified line number is an Image.create statement. I'm using paperclip and rubyzip. Here's the code:
def create
    @group = Group.new(params[:group])
    if @group.save && @group.errors.size == 0
      @photo_dir = "#{Rails.root}/tmp/#{@group.zip_file_name.chomp(".zip")}"
      Dir.mkdir(@photo_dir) if !File.directory?(@photo_dir)
      image_params = Hash.new
      image_params[:group_id] = @group.id
      image_params[:width] = @group.width
      image_params[:height] = @group.height
      Zip::ZipFile.open(@group.zip.path) do |zipfile|
    zipfile.each do |file|
      zipfile.extract(file, @photo_dir + "/#{file.name}") if !File.exists?(@photo_dir + "/#{file.name}")
      image_params[:photo] = File.open(@photo_dir + "/#{file.name}")
      Image.create(image_params)
    end
      end
      @group_images = Image.where(group_id: @group.id).to_a
      File.delete(@group.zip.path)
      Zip::ZipFile.open(@group.zip.path, Zip::ZipFile::CREATE) do |zipfile|
    @group_images.each do |file|
      zipfile.add(file.photo_file_name, file.photo.path(:thumb))
    end
      end
      redirect_to @group
    else
      render 'new'
    end
  end

Any help will be greatly appreciated.

Last edited by clear2codeu (2012-07-21 15:21:47)