4

我在我的应用程序控制器中添加了一个辅助方法:

def unzip (file, destination)
    Zip::File.open(file) do |zip_file|
        zip_file.each do |f|
            f_path = File.join(destination, f.name)
            FileUtils.mkdir_p(File.dirname(f_path))
            f.extract(f_path) 
        end
    end
end

我得到了错误:

private method `open' called for Zip::File:Class

当我在 Interactive Ruby shell 中运行它时,它运行良好。我如何在 Rails 4 上实现它?

4

0 回答 0