Topic: undefined method `columns' for #<Array:0xb7059c90>

As the title suggests, I'm getting this error message:

undefined method `columns' for #<Array:0xb7059c90>

when trying to open an image for re-sizing. Here are the two relevant methods in the Rails model:

    def picture=(picture_field)
        unless picture_field.original_filename.nil? || picture_field.content_type.chomp !~ /^image/
            @temp_file = picture_field
            @filename = base_part_of(picture_field.original_filename)
            @content_type = picture_field.content_type
           
            self.image_name = base_part_of(picture_field.original_filename)
            self.content_type = picture_field.content_type.chomp
        end
    end
   
    def after_save
        if @temp_file
            File.open("#{RAILS_ROOT}/media/#{@filename}", "wb") do |f|
                f.write(@temp_file.read)
            end
            img = Magick::Image.read("#{RAILS_ROOT}/media/#{@filename}")
            logger.debug("Got image #{img.inspect}")
            newsize = get_new_dimensions(img.columns, img.rows, 300, 190)
            img = img.thumbnail(*newsize)
            img.write "#{RAILS_ROOT}/media/#{@filename}"
        end
    end

Does anyone have any idea why it would give the error? ImageMagick and RMagick both seem to be installed fine on the server.

Last edited by adamp (2006-07-11 04:29:51)

Re: undefined method `columns' for #<Array:0xb7059c90>

Never mind - I'd missed the .first off the end of the Image.read call (line 17 above) so it should've been:

      img = Magick::Image.read("#{RAILS_ROOT}/media/#{@filename}").first